quinta-feira, 21 de novembro de 2019

This post will write about a different subject. A couple of posts before I wrote about my last travel. Now I will show another side of myself. I have studied Math and Programming.

I liked to connect Math's concepts to Science Computer, I believe there are many ways to learn and know the computer, but I always try to use always Math to solver a problem. This moment, I changed countries in January 2019, I live in Sydney, Australia now, we have been lived since January 2019.

So, I will start with the algorithms. I define algorithms with many synchronized steps with the goal to fix or resolve a problem.

The first algorithm I will describe is Fizz Buzz.

Given an array of the number and I will interact with the array, and check conditions to print something.

It is the simple algorithm for started, the problem is: Print Fizz is the number is multiple of 3 Print Buzz if the number is multiple of 5, if the number is multiple 3 and 5 print FizzBuzz, otherwise the number is print.


public class FizzBuzz {

public FizzBuzz(int size) {
for(int i = 1; i <= size; i++) {
boolean isMultiThree = i % 3 == 0;
boolean isMultiFive = i % 5 == 0;
if (isMultiThree && isMultiFive) {
System.out.println("Fizz Buzz");
}
else if (isMultiThree) {
System.out.println("Fizz");
}
else if (isMultiFive) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
public static void main(String[] args) {
new FizzBuzz(100);
}
}

Nenhum comentário: