FizzBuzz
Print the numbers from 1 to n, one per line, but:
- for multiples of 3, print
Fizzinstead of the number, - for multiples of 5, print
Buzz, - for multiples of both 3 and 5, print
FizzBuzz.
Input
One line with n.
Output
n lines.
Constraints
- 1 ≤
n≤ 1000
The input is read for you. The starter code puts it in variables; write your code under Your code here and print the answer. Changed the code already? Reset () brings the starter back.
Example 1
Input
5
Output
1 2 Fizz 4 Buzz
Why:
3 is a multiple of 3 and 5 a multiple of 5.
Example 2
Input
15
Output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Why:
15 is a multiple of both, so it is FizzBuzz.
Hints
Was this a good challenge?
- Solved by
- 0
- Submissions
- 0
- Accepted
- –