FizzBuzz

We use this kata to introduce the fundamentals of classic TDD

Overview

The FizzBuzz kata is based on the classroom game of the same name used to teach children about division. Starting from 1, each student in turn calls out the next number. However, if the number is divisible by 3 then they must call out 'Fizz', if it's divisible by 5 then 'Buzz' or if it's divisible by both 3 and 5 then 'FizzBuzz'.

Objectives

  • Write a program that prints the numbers from 1 to 100.

    • If the number is a multiple of 3 print 'Fizz' instead of the number.

    • If the number is a multiple of 5 print 'Buzz' instead of the number.

    • If the number is a multiple of both 3 and 5 print 'FizzBuzz' instead of the number.

Example

The output should look like this:

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

Last updated