Java/fizzbuzz.java

21 lines
544 B
Java
Raw Normal View History

2024-09-04 12:55:46 +02:00
public class fizzbuzz{
public static void main(String[] args) {
Integer i = 1;
while (true) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("fizzbuzz");
i++;
} else if (i % 3 == 0) {
System.out.println("fizz");
i++;
} else if (i % 5 == 0) {
System.out.println("buzz");
i++;
} else {
System.out.println(i);
i++;
}
}
}
}