FizzBuzz
InterviewTime limit1sMemory limit512 MB
Print the numbers 1 through N, writing Fizz for multiples of X, Buzz for multiples of Y, and FizzBuzz for multiples of both.
- Level
Easy1 of 10
- Topics
- Implementation, Math, Brute force, Simulation
- Solved
- No attempts yet
Problem
According to Wikipedia, FizzBuzz is a word game that teaches children about division. That may or may not be true, but the question is commonly used to torment fresh computer science graduates in programming interviews.
The rule is simple. Print the integers from to in order, replacing every multiple of with Fizz and every multiple of with Buzz. A number that is a multiple of both and is printed as FizzBuzz.
Input
The first line contains three integers , and separated by spaces ().
Output
Print the integers from to in order, one per line. Replace the multiples of with Fizz, the multiples of with Buzz, and the multiples of both and with FizzBuzz.