Skip to content

Commit

Permalink
Shortest Fizz Buzz solution for java
Browse files Browse the repository at this point in the history
  • Loading branch information
jillhkm authored Oct 8, 2018
1 parent d4b7753 commit 715497b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions problems/shortest-fizz-buzz/shortestFizzBuzz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ShortestFizzBuzz {
public static void main(String[] args) {

for (int x = 1; x <= 100; x++) {
System.out.println();
if (x % 3 == 0) {
System.out.print("fizz");
}
if (x % 5 == 0) {
System.out.print("buzz");
} if (x % 3 != 0 && x % 5 != 0) {
System.out.print(x);
}
}
}
}

0 comments on commit 715497b

Please sign in to comment.