echo "Enter a number: "
read c
x=$c
sum=0
r=0
n=0
while [ $x -gt 0 ]
do
r=`expr $x % 10`
n=`expr $r \* $r \* $r`
sum=`expr $sum + $n`
x=`expr $x / 10`
done
if [ $sum -eq $c ]
then
echo "It is an Armstrong Number."
else
echo "It is not an Armstrong Number."
fi
--------------------------------------------------------------------------------------------------------------
OUTPUT
Enter a number:
153
It is an Armstrong Number.
15 comments:
thank you so much ...!! :)
it's helpful
Thnx...realy its very help ful
In this program if i give a four digit number or a number less than 3 digits, for eg. If i give input as 2 then it will give output as not armstrong, which is wrong. This program will only work for 3 digit numbers. So junior get your concept cleared first.
there are six Armstrong numbers in the range of 0 and 999.
Armstrong number 1: 0
Armstrong number 2: 1
Armstrong number 3: 153
Armstrong number 4: 370
Armstrong number 5: 371
Armstrong number 6: 407
pls give code of lcm of two no. in cygwin shell script
Đơn vị vận chuyển gửi hàng từ việt nam sang Hoa Kỳ
Công ty vận chuyển gửi hàng từ việt nam sang Lôn-đôn chi phí rẻ
Đơn vị ship nhanh hàng hóa từ việt nam sang thái lan chi phí thấp
2 is armstrong number?
its really useful...and very simple...thankyou
Yes obvio
Sorry but their are some error why?
Okay
GOOD
good one . Cyber Security Quiz
wrong
i've tried many code, but yours work nice and easy
Post a Comment