Skip to main content

← Basics

FizzBuzz

easy

Read n. Print the numbers 1 to n, one per line, but print Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for multiples of both.

Example 1: input

5

Output

1
2
Fizz
4
Buzz

Example 2: input

15

Output

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

Plus 2 hidden tests when you check your answer.

Your solution

Read from standard input and print the answer. Run it on the examples as often as you like, then check it against every test.

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.