echo "Enter a number to check whether a number is perfect number or not "
read num
b=1
c=0
while [ $b -lt $num ]
do
if test `expr $num % $b` -eq 0
then
c=`expr $c + $b`
fi
b=`expr $b + 1`
done
if test $c -eq $num
then
echo "$num is a perfect number"
else
echo $num is not a perfect number
fi
No comments:
Post a Comment