FizzBuzz
Read a number n and print the numbers from 1 to n, one per line, except:
- for multiples of 3 print
Fizz, - for multiples of 5 print
Buzz, - for multiples of both 3 and 5 print
FizzBuzz.
Input
5
Expected output
1 2 Fizz 4 Buzz
Input
15
Expected output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Show a hint
Check for multiples of 15 first. If you check 3 first, 15 prints Fizz and never reaches FizzBuzz.
Show a solution
Loading the editor…
Run the tests to check your solution.