jeudi 22 février 2018

shell script to print multiplication table

This is a simple Bash shell script to print out the multiplicaiton
./table.sh 5 10
0*10=0
1*10=5
2*10=10
3*10=15
4*10=20
5*10=25
6*10=30
7*10=35
8*10=40
9*10=45

Version 1
#! /bin/bash

for i in  {0..12}
do
    echo "$i*$1=" $(($i*$1))
done



Version 2

#! /bin/bash
for ((number=0; number<$2; number++))
do
echo "$number*$2="$(($number*$1))
done


 Run table.sh
chmod u+x table.sh
./table.sh 5 10