Factorial of a Number [Shell Program]



echo "Enter a
number"


read n


f=1


if [ $n -eq 0 ]


then


echo "Factorial
is: 1"


else


while [ $n -ge 1 ]


do


f=`expr $f \*
$n`


n=`expr $n - 1`


done


echo "Factorial
is:"
$f


fi





0 Comments