10. Check strong number.
PROGRAM:
echo "Enter the number:"
read n
fact=1
if [ $n -eq 0 ]
then
echo "fact = "1
else
for i in `seq 1 $n`
do
fact=`expr $fact \* $i`
done
echo "fact = $fact"
fi
OUTPUT:
[bgc@localhost ~]$ sh 11.sh
Enter a number:
145
145 is a strong number
[bgc@localhost ~]$ sh 11.sh
Enter a number:
2
2 is a strong number
[bgc@localhost ~]$ sh 11.sh
Enter a number:
23
23 is not a strong number
[bgc@localhost ~]$
No comments:
Post a Comment