Skip to content

Instantly share code, notes, and snippets.

@fordarnold
Last active August 29, 2015 14:05
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 fordarnold/2c823b8bcf07cf2ca416 to your computer and use it in GitHub Desktop.
Save fordarnold/2c823b8bcf07cf2ca416 to your computer and use it in GitHub Desktop.
Java Class for the popular Fizz-Buzz game :D
/**
* FizzBuzz java class
*
* @author David Levine
* @source Quora.com
*
**/
public class FizzBuzz {
public static void main(String[] args) {
for (int i=1; i <= 100; i++) {
if (i%15 == 0)
System.out.println("FIZZ-BUZZ");
else if (i%3 == 0)
System.out.println("FIZZ");
else if (i%5 == 0)
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