According to Wikipedia, FizzBuzz is a group word game for children to teach
them about division. This may or may not be true, but this question is
generally used to
torture screen young computer science graduates during
Basically, this is how it works: you print the integers from \(1\) to \(N\),
replacing any of them divisible by \(X\) with
Fizz or, if they are divisible
by \(Y\), with
Buzz. If the number is divisible by both \(X\) and \(Y\), you
Check the samples for further clarification.
Prompt the user for three integers, \(X\), \(Y\), and \(N\), in that order. You may assume the user will enter integers such that \(1 \leq X < Y \leq N \leq 100\).
Print integers from \(1\) to \(N\) in order, each on its own line, replacing the ones
divisible by \(X\) with
Fizz, the ones divisible by \(Y\) with
Buzz and ones
divisible by both \(X\) and \(Y\) with
Lab I/O Format
Your program should use the Lab Input/Output Format, as described below:
- When prompting for input, use the prompt string
WORDis a single, uppercase word which describes the input.
- When providing output that will be graded, start the line with
OUTPUT. Think of this as "boxing your answer" on a math worksheet, it lets us quickly find your answer. We will ignore any lines which do not start with
- You may interleave the inputs and outputs in any order you wish. For example, you might want to recieve all of your inputs (order of inputs still matters!), then print all of your outputs (order of outputs still matters!), or you might want to do input/output, input/output, etc.
Example Interaction 1
X> 2 Y> 3 N> 7 OUTPUT 1 OUTPUT Fizz OUTPUT Buzz OUTPUT Fizz OUTPUT 5 OUTPUT FizzBuzz OUTPUT 7
Example Interaction 2
X> 2 Y> 4 N> 7 OUTPUT 1 OUTPUT Fizz OUTPUT 3 OUTPUT FizzBuzz OUTPUT 5 OUTPUT Fizz OUTPUT 7
Example Interaction 3
X> 3 Y> 5 N> 8 OUTPUT 1 OUTPUT 2 OUTPUT Fizz OUTPUT 4 OUTPUT Buzz OUTPUT Fizz OUTPUT 7 OUTPUT 8
This problem was derived from a problem by Darko Aleksic. License is CC BY-SA.