Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Created October 2, 2012 00:41
Show Gist options
  • Select an option

  • Save RyanScottLewis/3815497 to your computer and use it in GitHub Desktop.

Select an option

Save RyanScottLewis/3815497 to your computer and use it in GitHub Desktop.
Even Number Printing
int limit = 100;
// moop through each number from 1 to the limit (100)
for(int i=1; i <= limit; i++){
// everything in this block of code will be ran for each number
// if the number is divisible by 2 then it is even
if (i % 2 == 0) {
// print out the number with a space after it
System.out.print(i + " ");
}
// if the number is divisible by 10 then it is 10, 20, 30, etc..
if (i % 10 == 0) {
// print out a new line
System.out.print("\n");
// print out the bar
System.out.print("================");
// print out another new line
System.out.print("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment