Monday, October 28, 2013

To find a factorial of a given no.

 #To find a factorial of a given no.
fact=1
ie=1
echo -e "Enter a number:\c"
read a
while [ $ie -le $a ]
do
        fact=`expr $fact \* $ie`
        ie=`expr $ie + 1`
done
echo -e "Multilpication of $a number is $fact."
#OUTPUT
#Enter a number:5
#Multilpication of 10 number is 120.

No comments:

Post a Comment