Easy · Math

Fizzbuzz

Given a positive integer n, return a list of n strings whose i-th entry (for i = 1..n) is "FizzBuzz" if i is divisible by both 3 and 5, "Fizz" if it is divisible only by 3, "Buzz" if it is divisible only by 5, and otherwise i written in decimal.

Examples

Example 1

n = 5

Output: [1, 2, Fizz, 4, Buzz]

Example 2

n = 8

Output: [1, 2, Fizz, 4, Buzz, Fizz, 7, 8]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Math problems