echo "Enter the number"
read n
f=1
while [ $n -gt 0 ]
do
f=`expr $f \* $n`
n=`expr $n - 1`
done
echo "factorial= $f"
OUTPUT
biswarup@biswarup-desktop:~$ sh
$ sh fact.sh
Enter the number
3
factorial= 6
$
read n
f=1
while [ $n -gt 0 ]
do
f=`expr $f \* $n`
n=`expr $n - 1`
done
echo "factorial= $f"
OUTPUT
biswarup@biswarup-desktop:~$ sh
$ sh fact.sh
Enter the number
3
factorial= 6
$
No comments:
Post a Comment