It seems that in every interview ever, this question has been asked :
Print out all the numbers between 1 and 100. If a number is divisible by 3, print “fizz” next to it. If a number is divisible by 5, print “buzz” next to it. If it is divisible by both, print “fizzbuzz” next to it.
Naturally there are many solutions to this problem. I will give my first gut-feel solution here.
public static void main(String[] args) { for (int i=0; i <= 100; i++){ System.out.print(i + " "); if (i%3 == 0){ System.out.print("Fizz"); } if (i%5 == 0) { System.out.print("Buzz"); } System.out.println(); } }