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);
}
}
}

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s