[143845 views]
An Integer number in which the sum of the cubes of its digits is equal to the number itself is called Armstrong Number. For example, 153 is an Armstrong number since 1**3 + 5**3 + 3**3 = 153.
(NOTE: 5**3 is nothing but 5*5*5)
We first take input from user and store it in variable n. Then we initialize 2 variables temp to n and sum to 0. We calculate the cube of last digit by this expression [(n%10)*(n%10)*(n%10)] and add it to value of sum and also divide n by 10. We repeat the above step until n is greater than or equal to 0. At last, we check whether sum is equal to temp, if yes Print "Number is Armstrong Number" else print "Number is Not Armstrong Number".
Thanks for giving valuable information
You are doing great and website is not fancy like programiz
Thank you for above algorithm It was really useful
Thank you for the Notes. Was very useful.
bro thanking for your post
Excellent. Just a note in the loop of while the condition should be "while (num>0)" cause' of add the "=" it doesn't work. Thank you
@trunks, while (num>=0) works properly. I tried it myself