Monday 9 July 2012

Write a sccript 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:10
Multilpication of 10 number is 3628800.

0 comments:

Post a Comment