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





Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C