Monday, 21 October 2013

fact

set  -vx
echo "enter no"
read  n
fact=1

if [ $n -eq 0 ]
then
 fact=0
fi

while [ $n -gt 0 ]
do
fact=`expr $fact \* $n `
n=`expr $n - 1 `
done

echo "facto:$fact"

No comments:

Post a Comment