Fizz Buzz

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

The iconic coding interview question to filter out bad programmers. Fizz Buzz. It's deceptively simple, yet 199 out of 200 interviewees cannot solve the problem. The task is simple: Print out a list of numbers from 1 to N, but replace multiples of 3 with fizz, multiples of 5 with buzz and multiples of both with fizzbuzz. Can you pass the interview?

Input Specification

There will be one line of input containing one integer, N, the number to stop at.

20 \le N \le 10^5

Output Specification

Output the numbers from 1 to N (inclusive), replacing multiples of 3 with fizz, multiples of 5 with buzz and multiples of both with fizzbuzz.

Please note that endl for C++ users will be too slow. Use \n or printf instead.

Sample Input

20

Sample Output

1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz

Comments

There are no comments at the moment.