FizzBuzz
Completed
Read n. For 1 to n print FizzBuzz for multiples of 15, Fizz for multiples of 3, Buzz for multiples of 5, otherwise the number.
Input
One integer.
Output
n lines.
Example
Input
15
Output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Editor
Python
Hints
Check the multiple-of-15 case first.
Solution explanation
The order of the conditions matters: 15 is also a multiple of 3 and 5.
Show solution
n = int(input())
for i in range(1, n + 1):
if i % 15 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)