Headlines
Loading...
Program in UNIX to check entered number is Armstrom number or not

Program in UNIX to check entered number is Armstrom number or not

Write a shell script to check entered number is Armstrom number or not
echo enter any Number
read nu
num=$nu
ans=0
while [ $num -ne 0 ]
do
        a=`expr $num % 10`
        ans=`expr $ans + "(" $a "*" $a "*" $a ")"`
        num=`expr $num / 10`
done

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