by CodeChum Admin
Instructions:
Instructions
Input
A line containing an integer.
15
Output
Multiple lines containing a string.
Fizz
Buzz
Fizz
Fizz
Buzz
Fizz
FizzBuzz
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int number = in.nextInt();
for (int i = 1; i <= number; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("FizzBuzz");
}else
if (i % 3 == 0) {
System.out.println("Fizz");
}else
if (i % 5 == 0) {
System.out.println("Buzz");
}
}
in.close();
}
}
Comments
Leave a comment