Headlines
Program in UNIX to check entered number is perfect or not

Program in UNIX to check entered number is perfect or not

Write a shell script to check entered number is perfect or not
echo Enter a number to find its perfect or not.
read no
i=1
ans=0
while [ $i -le `expr $no / 2` ]
do
        if [ `expr $no % $i` -eq 0 ]
        then
                ans=`expr $ans + $i`
        fi

        i=`expr $i + 1`
done

if [ $no -eq $ans ]
then
        echo $no is perfect number.
else
        echo $no is not a perfect number.
fi
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***