Sunday, 3 April 2016

1. Shell script to find the factorial of a given number.

echo "enter the number"
read n
i=1
fact=1
while [ $i -le $n ]
do
    fact=`expr $fact \* $i`
    i=`expr $i + 1`
done
echo "factorial of a number = $fact"

No comments:

Post a Comment