Note
|
The examples shown here are generated from the source code. They therefore represent the behavior of the application at any times. Non regression is ensured by checking the absence of change in this document. Learn more here https://github.com/sfauvel/documentationtesting |
View source of project on Github
Fizz buzz test
Fizz buzz is a group word game for children to teach them about division.
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz “.
Sample output
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz… etc up to 100
Output in a table
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
1 |
2 |
Fizz |
4 |
Buzz |
Fizz |
7 |
8 |
Fizz |
Buzz |
11 |
Fizz |
13 |
14 |
FizzBuzz |
16 |
17 |
Fizz |
19 |
Buzz |
Rules
Return given number
When number is not divisible by five or three, returns the number.
FizzBuzz(1) = 1
FizzBuzz(2) = 2
FizzBuzz(4) = 4
FizzBuzz(22) = 22
Return fizz when divisible by three
When number is divisible by three, returns Fizz.
FizzBuzz(3) = Fizz
FizzBuzz(9) = Fizz
Return buzz when divisible by five
When number is divisible by five, returns Buzz.
FizzBuzz(5) = Buzz
FizzBuzz(25) = Buzz
Return fizzbuzz when divisible by three and five
When number is divisible by three and five, returns FizzBuzz.
FizzBuzz(15) = FizzBuzz
FizzBuzz(60) = FizzBuzz
Values by result
List of values (between & to 30) that give a specific result
-
FizzBuzz: [15, 30]
-
Fizz: [3, 6, 9, 12, 18, 21, 24, 27]
-
Number: [1, 2, 4, 7, 8, 11, 13, 14, 16, 17, 19, 22, 23, 26, 28, 29]
-
Buzz: [5, 10, 20, 25]