CSCI-101: Intro to Computer Science
Python Course

FizzBuzz

Note: You will implement this program twice. For Lab 4A, you should use a while loop in your implementation, and for Lab 4B, you should use a for loop in your implementation.

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 programming interviews.

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 print FizzBuzz instead.

Check the samples for further clarification.

Input

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\).

Output

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 FizzBuzz.

Lab I/O Format

Your program should use the Lab Input/Output Format, as described below:

  • When prompting for input, use the prompt string WORD>, where WORD is 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 OUTPUT.
  • 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

License

This problem was derived from a problem by Darko Aleksic. License is CC BY-SA.