Skip to content

Instantly share code, notes, and snippets.

@LukeMcNemee
Created October 4, 2015 12:11
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 LukeMcNemee/3f4ec9f19c642653dab3 to your computer and use it in GitHub Desktop.
Save LukeMcNemee/3f4ec9f19c642653dab3 to your computer and use it in GitHub Desktop.
Java For cycles, print small multiplication table
public class Multiples {
public static void printMultiples(int max){
System.out.print(" | ");
for(int i = 1; i <= max; i++){
System.out.print( i + " ");
}
System.out.println("");
System.out.print( "--|--");
for(int i = 1; i <= max; i++){
System.out.print( "---");
}
System.out.println("");
for(int i = 1; i <= max; i++){
System.out.print( i + " | ");
for(int j = 1 ; j <= max; j++){
System.out.print(i*j + " ");
if(i*j < 10){
System.out.print(" ");
}
}
System.out.println("");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment