LeetCode #412

Write a program that outputs the string representation of numbers from 1 to n.

But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.


n = 15,


Pseudo code

  1. Loop through all numbers from 1 to n.
  2. If it’s 3’s multiple,
    • If it’s also 5’s multiple, push “FizzBuzz” to the output array
    • If not, just push “Fizz”
  3. If not 3’s multiple, but it’s 5’s multiple, push “Buzz”
  4. If neither 3’s or 5’s multiple, just push the number itself but convert to string.


See the Pen 412. Fizz Buzz by Cherry Wang (@chryw) on CodePen.