echo "Enter the no"
read n
i=0
k=$n
while test $n -ne 0
do
u=`expr $n % 10`
i=`expr $i + $u \* $u \* $u`
n=`expr $n \/ 10`
done
if test $k -eq $i
then
echo "$k is a armstrong number"
else
echo "$k is not armstrong number"
fi
~
~
"arm" 16L, 225C
15,1 All
Output:
"arm" 16L, 225C written
[eceb33@linuxserver eceb33]$ sh arm
Enter the no
153
153 is a armstrong number
No comments:
Post a Comment