Fizz Buzz Whiz

Level: Beginner 15–30 min

Concepts: Algorithms


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

InputResult
11
22
3Fizz
44
5Buzz
6Fizz
9Fizz
10Buzz
15FizzBuzz
20Buzz
30FizzBuzz
75FizzBuzz

Bonus

Add the following new rule, if a number is prime return Whiz. Only worry about numbers up to 100.

InputResult
11
2Whiz
3FizzWhiz
44
5BuzzWhiz
6Fizz
7Whiz
10Buzz
15FizzBuzz
30FizzBuzz