Count from 1 to n and write each number down as a string, except that some numbers are replaced by a word:
3 and 5 becomes "FizzBuzz";3 becomes "Fizz";5 becomes "Buzz";"7".Return the n strings in order, so the entry at index 0 stands for the number 1.
3 and 6 are multiples of 3, and 5 is a multiple of 5. The rest stay as numbers.
15 is the first number divisible by both 3 and 5, so it is the first "FizzBuzz".
Constraints
1 <= n <= 10⁴Every number is handled on its own, so one pass from 1 to n is all it takes. The only care needed is the order of the checks.
6