Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 8, 2019 23:34
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 parzibyte/0fa3ae632a002a6b8cd701c8ba641b62 to your computer and use it in GitHub Desktop.
Save parzibyte/0fa3ae632a002a6b8cd701c8ba641b62 to your computer and use it in GitHub Desktop.
/*
Tablas de multiplicar en Java
https://parzibyte.me/blog
*/
class Main {
public static void main(String[] args) {
int numeroTabla = 9; // La tabla del nueve
imprimirTabla(numeroTabla);
}
public static void imprimirTabla(int numeroDeTabla) {
for (int x = 1; x <= 10; x++) {
String formato = "%d x %d = %d";
String linea = String.format(formato, numeroDeTabla, x, numeroDeTabla * x);
System.out.println(linea);
}
}
}
/*
Salida:
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
9 x 10 = 90
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment