LeetCode 412. Fizz Buzz



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”.



We have iterate number 1 to n.

  • If (number % 3 == 0 && number % 5 == 0), output “FizzBuzz”.
  • If (number % 3 == 0), output “Fizz”.
  • If (number % 5 == 0), output “Buzz”.
  • For all other cases, just output the string value of the number.

Video Tutorial

Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *