Problem 797
FizzBuzz
Easy · 10 pts · Basics, Loops, Conditionals
Problem
For every number i from 1 to N, print Fizz if i is divisible by 3, Buzz if it is divisible by 5, FizzBuzz if it is divisible by both 3 and 5, and the number itself otherwise. Print the results separated by spaces. The usual mistake is checking 3 or 5 before checking 15, so test divisibility by both first.
Input
A single integer N.
Output
Print the N results separated by spaces.
Constraints
1 <= N <= 10000
Example input
15
Example output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Explanation
For N = 15 the results run 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz; 15 is divisible by both 3 and 5.