Skip to content

Instantly share code, notes, and snippets.

@DanielGGordon
Created June 2, 2015 16:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DanielGGordon/c4d887c5e94c07475cf0 to your computer and use it in GitHub Desktop.
public class FizzBuzz {
public static void main (String args[]) {
fizzBuzz(100);
}
public static void fizzBuzz (final int n) {
for(int i = 1; i <= n; i++) {
if (((i % 5) == 0) && ((i % 3) == 0)) {
System.out.print("fizzbuzz\n");
}
else if ((i % 5) == 0){
System.out.print("fizz ");
}
else if ((i % 3) == 0) {
System.out.print("buzz ");
}
else {
System.out.print(i + " ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment