• 0

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 :