FizzBuzz Problem

Found about FizzBuzz problem here

I wrote Java program for it in 6 minutes including testing and debugging. [ Yes 🙁 I didn’t get it correct , first time ]

However, here is my solution:


public class FizzBuzz
{
public static void main(String args[])
{
for(int i=1;i<101;i++){

if(i%15==0)
System.out.println("FizzBuzz");
else if(i%5==0)
System.out.println("Buzz");
else if(i%3==0)
System.out.println("Fizz");
else
System.out.println(i);
}
}
}

Published by Chaitanya

I am a family man, perpetual learner, coffee drinker, dessert eater and Happiness Engineer at Automattic. I also read, write, move, and meditate.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: