Skip to content
Onsite

Fizz Buzz

EasyP2Coding

Return the numbers from 1 to n as strings, with three replacements:

  • a multiple of both 3 and 5 becomes "FizzBuzz"
  • a multiple of 3 becomes "Fizz"
  • a multiple of 5 becomes "Buzz"

Every other number is its decimal text, such as "7". The result has exactly n entries.

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","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]

Constraints

  • 1 <= n <= 10^4

Hints

Run checks the 3 visible tests, Submit all 8.