Thursday, 11 December 2014

Shell Script to find the Factorial of a number

Write a Shell Script to find the Factorial of a number

Solution:
echo "Enter a number"
read n
f=1
i=1
while test $i -le $n
do
f=`expr $f \* $i`
i=`expr $i + 1`
done
echo " Factorial of $n is $f"

Execution:


No comments:

Post a Comment