Coding/Programming Question: Fizz-Buzz
- A very common general programming question to quickly white board that shows a general knowledge of writing code.
Respostas da entrevista
Sigiloso
28 de dez. de 2016
Wrote out a quick Java example. Simple and easy.
Sigiloso
8 de mar. de 2020
public static void main(String[] args) {
int[] intArr = { 3, 15 }; //number of test cases, here 2
for (int i = 0; i < intArr.length; i++) {
for (int j = 1; j <= intArr[i]; j++) {
if (j % 15 == 0) {
System.out.print("FizzBuzz ");
} else if (j % 3 == 0) {
System.out.print("Fizz ");
} else if (j % 5 == 0) {
System.out.print("Buzz ");
} else {
System.out.print(j+" ");
}
}
System.out.println();
}
}