echo -n "Enter number : "
read n
num=$n
sd=0
nnum=0
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
n=$(( $n / 10 ))
pow=$(($sd * $sd * $sd))
nnum=$(( $nnum +$pow ))
done
if test $num -eq $nnum
then
echo "$num is a Armstrong Number"
else
echo "$num is not an Armstrong Number"
fi
No comments:
Post a Comment