httpiimgurcomIPidavLpng Write a shell script to calculate fa
http://i.imgur.com/IPidavL.png
Write a shell script to calculate factorial of a given integer number. Please name your shell script as factorial.sh. The integer number should be given on command line. The sample outputs are as below: $./factorial.sh 2 the factorial of 2 is 2 $./factorial.sh 4 the factorial of 4 is 24 $./factorial.sh 5 the factorial of 4 is 120Solution
#!/bin/bash
n=$1
a=1
ct=0
while [ $n -ne $ct ]
do
ct=`expr $ct + 1`
a=`expr $a \\* $ct`
done
echo \"The factorial of $n is $a\"
