Divisibility labels
Return the strings for integers 1 through n: Fizz for multiples of 3, Buzz for 5, FizzBuzz for both, otherwise the decimal number. n is nonnegative.
number = 15
print(number % 3 == 0 and number % 5 == 0)Reason about the state
Check divisibility by both factors before either individual factor. Build one output per number in linear time. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return the strings for integers 1 through n: Fizz for multiples of 3, Buzz for 5, FizzBuzz for both, otherwise the decimal number. n is nonnegative.
The explanation opens here once every check passes.