## Introduction

The following post is a little bit different from my other posts as it does not solve any of your Linux configuration problems. Apologies there! This post is an attempt to kill multiple birds with one stone, hence expose children to a command line, avoid web flash and ads driven multiplication practice tests online and most importantly gain some multiplication skills along the way.

My daughter reached the age where she is required to perform multiplication calculation at school. So together we have developed a below Bash script to take her 1×1 to 10×10 multiplication tables practice to the next level. She approved all the output colours with a “cool” mark, and to my surprise, she was very quickly able to correct my forgotten closing quotation marks during the development thus significantly improving development efficiency:-)

## Example

Below is a video sample of running `multiplication.sh`

script with 2 random multiplication, addition, subtraction and division questions:

The script accepts a single argument which is used to set a number of questions asked during the multiplication practice quest. If no argument supplied, it defaults to 20 questions.

## Run Multiplication Practice Test

The script is now uploaded on GitHub so feel free to grub it from there, make it executable and run it:

$ git clone https://github.com/linuxconfig/multiplication-tables-practice.git $ cd multiplication-tables-practice/ $ ./multiplication.sh

Alternatively, apart of the default multiplication test the script also supports addition, subtraction a division. Examples:

### Multiplication

$ ./multiplication.sh ################################ What is the product of 1 x 6 ?

### Addition

$ ./multiplication.sh -a ################################ What is the sum of 3 + 5 ?

### Subtraction

$ ./multiplication.sh -s ################################ What is the result of 10 - 6 ?

### Division

$ ./multiplication.sh -d ################################ What is the division of 6 : 1 ?

## Changing Bash Output Colors

In case you wish to change the output script colors, pick your desired color code from the below table:

Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34 Green 0;32 Light Green 1;32 Cyan 0;36 Light Cyan 1;36 Red 0;31 Light Red 1;31 Purple 0;35 Light Purple 1;35 Brown 0;33 Yellow 1;33 Light Gray 0;37 White 1;37

Next, replace the color code with existing one. For example to change Cyan to Light Blue for `What is the product of`

change:

FROM:

printf "\\033[0;36mWhat is the product of $question ?\e[0m\n"

TO:

printf "\\033[1;34mWhat is the product of $question ?\e[0m\n"

## Credits

- Carmen Rendek – Design & Test control
- Ivo Valkov ( inspiretheme.com ) – help with code highlight HTML PRE tag implementation