Loading...
Loading...
In a classroom game, students count in turn. A student whose number is a multiple of 3 says Fizz, a multiple of 5 says Buzz, and a multiple of both 3 and 5 says FizzBuzz. Any other student just says the number.
Read one student's number and print what that student says.
FizzBuzz, Fizz, Buzz or the number itself.Example 1
Input
9
Output
Fizz
9 is a multiple of 3 only.
Example 2
Input
30
Output
FizzBuzz
30 is a multiple of both 3 and 5.
Example 3
Input
7
Output
7
7 is a multiple of neither, so the number is printed.
Try the problem first. Open one hint at a time.
A multiple of 3 means n % 3 == 0. Join two tests with && when both must be true.
Order matters: check "multiple of both" first, or 15 will stop at the Fizz branch.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor