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

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Math problems