GFSSOC '15 Fall J2 - Fizz Fuzz

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 16M

Problem types

While doing homework for computer science class, you stumble across an interesting problem asking you to simulate the popular game Fizz Fuzz. The rules for Fizz Fuzz are as follows: Simultaneously keep track of two numbers, both starting from 1, the first number increasing by one each round, the other number increasing by two each round. Every time you reach a number that is divisible by 7, output Fizz. Every time you reach a number divisible by 13, output Fuzz. If the number is divisible by both 13 and 7, instead of outputting Fizz or Fuzz, output Fizz Fuzz (the output might get confusing!). Otherwise, output the number. Can you simulate this game for N rounds?

Input Specification

The first and only line of input has one integer, N.

Output Specification

You should output N lines. the i^{th} line should correspond with the i^{th} round. That is, output the two numbers (or strings) space separated.


1 \le N \le 1\,000

Sample Input


Sample Output

1 1
2 3
3 5
4 Fizz
5 9
6 11
Fizz Fuzz
8 15
9 17

Note: As a further example, if the 2 numbers happen to be 91 and 91, you need to print Fizz Fuzz Fizz Fuzz.


  • 0
    niamp  commented on Nov. 16, 2015, 9:54 p.m.

    I'm getting wrong answers on test cases 3-10, however, other IDEs output the correct answer when I run the program. I've checked over my code and it seems okay. Is there a reason why I'm not getting them right?

    • 0
      awaykened  commented on Nov. 16, 2015, 10:19 p.m.

      try running the code through your head if num1 or num2 is equal to 91