Skip to content

Commit cf4c8c0

Browse files
committed
java fizzbuzz
1 parent 4f76918 commit cf4c8c0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

algorithms/PrimeNumbers.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,22 @@ public static void print_eratosfen2(int max_num) {
114114
}
115115
System.out.println("(" +cnt_iterat+ ")");
116116
} //print_eratosfen2
117+
118+
public static void fizzbuzz() {
119+
for(int i = 1; i<= 100; i++) {
120+
if(i%3 == 0 && i%5 == 0) System.out.print("FizzBuzz ");
121+
else if(i%3 == 0) System.out.print("Fizz ");
122+
else if(i%5 == 0) System.out.print("Buzz ");
123+
else System.out.print(i + " ");
124+
}
125+
} //fizzbuzz
117126

118127
public static void main(String[] args) {
119128
print_n2 (100);
120129
print_sqrt (100);
121130
print_eratosfen (100);
122131
print_eratosfen2 (100);
132+
fizzbuzz();
123133
}
124134

125135
}

0 commit comments

Comments
 (0)