Fizz Buzz
Collapse Content
Show Content
This is a classic basic programming challenge, which goes as follows:
Write a program that prints the numbers from 1 through 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Challenge
Print FizzBuzz as above with each number or word on its own line.
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.
Comments
Matt
Nov 18, 1:25 AMCompleted successfully, not checked off on the side list, though.
Кирилл Варивода
Jan 15, 6:25 AMMy code works fine! Admin, thanks you for explanation part after the task, picked up something new!
Davin
Jun 13, 7:46 AMNot checked off as well
Learneroo
Jun 15, 12:00 PM@Davin, did it get checked off when you went to the next page?
J.g. Dion
Nov 29, 11:05 AM'import java.util.*;
public class Main{
}'
For wathever reason its just printing FizzBuzz...help?
Bernard Mitchell
Jun 9, 3:11 PMI did mine a different way does it mean my code isn't as efficient or wrote very well?
Learneroo
Jun 9, 3:18 PMThere are many ways to solve this problem. Run-time efficiency doesn't matter for such small problems, but it's important to try to write clear code. See the featured answers for another possible solution.
z.z
Feb 25, 10:55 AMmy solution:
for(int i=1;i<=100;i++){
z.z
Feb 25, 10:55 AMfor(int i=1;i<=100;i++){
catypus
Jun 21, 2:51 AMMy stupid
else if((i%3 ==0) && (i%5==0)){
System.out.println("FizzBuzz");
}
doesn't seem to give FizzBuzz for 15! Why? GRRR
Pedro
Feb 23, 12:35 AM@catypus
the order of IF statement is important, if the printIn for 3 has already happened it wont overwrite with 3 & 5 printIn, try making that statement before the 3 and 5 individually.