Submissions disabled: This deployment is running in read-only mode for safety. Code execution is not available here.
← Back to all problems
Easy

FizzBuzz

Updated Jan 31, 2026

Problem

Given an integer n, print numbers from 1 to n, but:
- For multiples of 3, print "Fizz" instead of the number
- For multiples of 5, print "Buzz" instead of the number
- For multiples of both 3 and 5, print "FizzBuzz" instead of the number

Print each output on a new line.

Constraints

- 1 <= n <= 100

Follow Up

Can you solve this without using modulo operator?

Examples

Example 1

Input: n = 3
Output: ['1', '2', 'Fizz']

Example 2

Input: n = 5
Output: ['1', '2', 'Fizz', '4', 'Buzz']

Example 3

Input: n = 15
Output: ['1', '2', 'Fizz', '4', 'Buzz']...
15 is divisible by both 3 and 5, so it prints FizzBuzz

Function Signature

def fizzBuzz(self, n: int) -> list[str]

How to Submit

Implement a Solution class with a fizzBuzz method.

Your method will be called with the input parameters and should return the answer.