------------------------
/* FizzBuzz Program */
/*It prints number from 1 to 50
=>In place of multiple of 3 it print Fizz
=>In place of multiple of 5 it print Buzz
*/
class fizzbuzz
{
public static void main(String a[])
{
int i;
for(i=1;i<=50;i++)
{
if(i%(3*5)==0)
{
System.out.print("BuzzFizz");
}
else if(i%5==0)
{
System.out.print("Buzz");
}
else if(i%3==0)
{
System.out.print("Fizz");
}
else
{
System.out.print(i);
}
if(i%10==0)
{
System.out.println("\n");
}
else
{
System.out.print("\t");
}
}
}
}
0 comments:
Post a Comment