easy
strings
math
Given an integer n, return a list of strings from 1 to n where:
- multiples of 3 are replaced with
"Fizz", - multiples of 5 with
"Buzz", - multiples of both 3 and 5 with
"FizzBuzz", - otherwise the number itself as a string.
Examples
Example 1
Input: n = 5
Output: ["1","2","Fizz","4","Buzz"]
Example 2
Input: n = 15
Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
Example 3
Input: n = 3
Output: ["1","2","Fizz"]
Running will execute all 3 cases.