Shell program to calculate the factorial of a number

 Shell program to calculate the factorial of a number



echo "Enter a number"
read num

fact=1

while [ $num -gt 1 ]
do
  fact=$((fact * num))  #fact = fact * num
  num=$((num - 1))      #num = num - 1
done

echo $fact



Post a Comment

0 Comments

Ad Code

Responsive Advertisement