ARMSTRONG NUMBER

SOURCE CODE:
echo "Enter the number"
read n
t=$n
s=0
b=0
c=10
while [ $n -gt $b ]
do
r=`expr $n % $c`
i=`expr $r \* $r \* $r`
s=`expr $s + $i`
n=`expr $n / $c`
done
echo $s
if [ $s -eq $t ]
then
echo "Amstrong number"
else
echo "Not an Armstrong number"
fi

OUTPUT:
[examuser35@localhost Jebastin]$ sh amstrong.sh
Enter the number
213
36
Not an Armstrong number
[examuser35@localhost Jebastin]$ sh amstrong.sh
Enter the number
153
153
Armstrong number
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: