FastPrepFastPrep
Problem Brief

FizzBuzz Problem

NEW GRADOA

When given a number N, for each integer i in the range from 1 to N inclusive, print one value per line as follows:

  • If i is a multiple of both 3 and 5, print "FizzBuzz".
  • If i is a multiple of 3 but not 5, print "Fizz".
  • If i is a multiple of 5 but not 3, print "Buzz".
  • If i is not a multiple of 3 or 5, print the value of i.
  • Write an algorithm which follows the given instructions and prints the required output.

    Problem-solving restrictions: 0 < N < 2*10^6

    Input description: The input consists of an integer - inputNum, representing the given number (N).

    Output description: Print a line-separated output based on the given instructions for each value i in the set {1, 2, ... N} in ascending order.

    1Example 1

    Input
    inputNum = 5
    Output
    ["1", "2", "Fizz", "4", "Buzz"]
    Explanation
    Explanation should be very intuitive to us. Ace and Cheers~~ 🍻

    Constraints

    Limits and guarantees your solution can rely on.

    0 < N < 2*10^6
    public String[] fizzBuzz(int inputNum) {
      // write your code here
    }
    
    Input

    inputNum

    5

    Output

    ["1", "2", "Fizz", "4", "Buzz"]

    Sign in to submit your solution.