Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Fizz-Buzz challenge

Problem description :

Write a function that prints the numbers from 1 to 100.
But for multiples of three prints Fizz instead of the number and for the multiples of five prints Buzz.
For numbers which are multiples of both three and five prints FizzBuzz.

Input : N/A
Output : Numbers and Strings

Logic :

  • If the number is multiple of three, then update the output string with fizz.
  • If the number is multiple of five, then append Buzz to the output string.
  • Log the output string if not empty else prints the number.

Solution :

You may also like...

Leave a Reply

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