Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.