Skip to content

Instantly share code, notes, and snippets.

@rshepherd
Last active August 29, 2015 14:07
Show Gist options
  • Save rshepherd/82d1cedce44da6089ef4 to your computer and use it in GitHub Desktop.
Save rshepherd/82d1cedce44da6089ef4 to your computer and use it in GitHub Desktop.
A solution to the FizzBuzz faux-quiz.
public class FizzBuzz {
public static void main(String[] args) {
for(int i = 0 ; i < 100 ; ++i) {
boolean fizz = i % 3 == 0;
boolean buzz = i % 5 == 0;
if (fizz && buzz) {
System.out.println("FizzBuzz");
} else if (fizz) {
System.out.println("Fizz");
} else if (buzz) {
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