Skip to content

Instantly share code, notes, and snippets.

@MrBean83
Created May 12, 2015 15:52
Show Gist options
  • Save MrBean83/18527e6bdddc2d823ac2 to your computer and use it in GitHub Desktop.
Save MrBean83/18527e6bdddc2d823ac2 to your computer and use it in GitHub Desktop.
Simple "Fizz Buzz" Program
class FizzBuzz {
public static void main(String args[]) {
// Declare local variables
int num;
// Using a FOR loop for this program.
for (num = 1; num < 73; num++) {
if (num % 35 == 0)
System.out.println("FizzBuzz");
else if (num % 7 == 0)
System.out.println("Buzz");
else if (num % 5 == 0)
System.out.println("Fizz");
else
System.out.println(num);
} // end for
} // end main
} // end class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment