Skip to content

Instantly share code, notes, and snippets.

@tprochazka
Created August 30, 2012 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tprochazka/3522476 to your computer and use it in GitHub Desktop.
Save tprochazka/3522476 to your computer and use it in GitHub Desktop.
FizzBuzz
public class FizzBuzz {
/**
* @param args
*/
public static void main(String[] args) {
for (int i=1; i <= 100; i++) {
boolean m3 = i%3==0;
boolean m5 = i%5==0;
if (m3 && m5) {
System.out.println("FizzBuzz");
} else if (m3) {
System.out.println("Fizz");
} else if (m5) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment