Fizz Buzz Whiz
Return “Fizz”, “Buzz” or “FizzBuzz”.
For a given natural number greater zero return:
- “Fizz” if the number is divisible by 3
- “Buzz” if the number is divisible by 5
- “FizzBuzz” if the number is divisible by both 3 and 5
- The number if it is not divisible by both 3 and 5
Test Cases
Input | Result |
---|---|
1 | 1 |
2 | 2 |
3 | Fizz |
4 | 4 |
5 | Buzz |
6 | Fizz |
9 | Fizz |
10 | Buzz |
15 | FizzBuzz |
20 | Buzz |
30 | FizzBuzz |
75 | FizzBuzz |
Bonus
Add the following new rule, if a number is prime return Whiz. Only worry about numbers up to 100.
Input | Result |
---|---|
1 | 1 |
2 | Whiz |
3 | FizzWhiz |
4 | 4 |
5 | BuzzWhiz |