$ cat>factorial.sh
echo enter value of n
read n
If [$n –eq 0]
then
echo factorial of given number is 1
fi
If [$n -1t 0]
then
echo factorial of given number is not possible
else
temp = ‘expr $n – 1’
while [ $temp –gt 1]
do
$n = ‘expr $n \* $temp’
temp = ‘expr $temp – 1’
done
echo factorial of given number is $n
fi
echo enter value of n
read n
If [$n –eq 0]
then
echo factorial of given number is 1
fi
If [$n -1t 0]
then
echo factorial of given number is not possible
else
temp = ‘expr $n – 1’
while [ $temp –gt 1]
do
$n = ‘expr $n \* $temp’
temp = ‘expr $temp – 1’
done
echo factorial of given number is $n
fi
1 comments:
It works well:)
Post a Comment