Menu
CoddyTech

FizzBuzz

FizzBuzz is a counting game. Players count up from 1, but some numbers are replaced by words: a number divisible by 3 is said as Fizz, a number divisible by 5 as Buzz, and a number divisible by both 3 and 5 as FizzBuzz. Every other number is said as it is. The first fifteen turns go 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz.

The order of the checks is the whole trick. 15 is divisible by 3, so if you test for 3 first and return "Fizz" right away, you never reach the case for both. Check the combined rule first: a number divisible by both 3 and 5 is exactly a number divisible by 15. Then check 3, then 5, and only then fall back to the number itself.

The classic version prints the whole sequence. Here you answer for one number at a time: given n, return what a player says on turn n. For example, turn 9 is "Fizz", turn 10 is "Buzz" and turn 11 is "11".

Write a function named fizzBuzz that gets a positive integer n and returns a string: "FizzBuzz" if n is divisible by both 3 and 5, "Fizz" if it is divisible by 3 only, "Buzz" if it is divisible by 5 only, and otherwise n written as a decimal string (for example "7").

Constraints: 1 <= n <= 10^9.

Function

fizzBuzz(arg1: integer) → string
arg1integer
Returnsstring

Examples

Input
arg1 = 15
Output
"FizzBuzz"

lock icon+11 hidden tests on Submit

Reset code
def fizzBuzz(n):
    # Write code here
Test cases

Case 1

Case 2

Input

arg1 = 15

Expected

"FizzBuzz"