Home > Linux > Display Multiplication Table With A Command Line

Display Multiplication Table With A Command Line

If you forgot your multiplication table and happen to have a terminal window opened in Linux¬† at the time, here’s the command to use:

seq 9 | sed ‘H;g’ | awk -v RS=” ‘{for(i=1;i<=NF;i++)printf(“%dx%d=%d%s”, i, NR, i*NR, i==NR?”\n”:”\t”)}’

Same thing using perl:

Here’s the output:

Source (in French): http://www.tux-planet.fr/afficher-les-tables-de-multiplication-en-ligne-de-commande/

Categories: Linux Tags: Linux, perl, shell
  1. No comments yet.
  1. No trackbacks yet.