Replace Multiple of 3 with Fizz, of 5 with Buzz, and of both with FizzBuzz
Single File Programming Question
Problem Statement
Helen wants to implement a FizzBuzz program using a generic class named FizzBuzz that takes a number of any numeric type.
FizzBuzz is a popular programming problem where you need to print numbers from 1 to a given number but replace multiples of 3 with "Fizz", multiples of 5 with "Buzz," and multiples of both 3 and 5 with "FizzBuzz".
Assist Helen in developing the program.
Input:
format :The input consists of an integer N, representing the ending range for which FizzBuzz should be applied.
Output:
format :The program prints the FizzBuzz sequence from 1 to N in each line.
For each number, it should follow these rules:
If the number is divisible by 3, print "Fizz" If the number is divisible by 5, print "Buzz" If the number is divisible by both 3 and 5, print "FizzBuzz" Otherwise, print the number itself.
Refer to the sample output for formatting specifications.
Code constraints : 1 ≤ N ≤ 50
Sample test cases :
Input 1:
28
Output 1 :
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
Input 2 :
7
Output 2 :
1
2
Fizz
4
Buzz
Fizz
7