Skip to content
CodeShare
All problems

Fizz Buzz

The classic: Fizz for threes, Buzz for fives, FizzBuzz for both.

EasyMathStrings

Given an integer n, return an array with one string for each number from 1 to n:

FizzBuzz if the number is divisible by both 3 and 5, Fizz if it's divisible by 3, Buzz if it's divisible by 5, and otherwise the number itself, written as a string.

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

Constraints

  • 1 <= n <= 10^4