# Armstrong Number

Posted on December 28, 2014 by Shivaji Varma

An Armstrong number is a number such that the sum of its digits raised to the third power is equal to the number itself.

For example, 371 is an Armstrong number, since 3^3 + 7^3 + 1^3 = 371.

Another example, 153. 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.

Program to find whether the given number is an Armstrong number or not.

### Code

```
def isArmstrong(num):
temp = num
sum = 0
digit = 0
while(temp != 0):
digit = temp % 10
sum = sum + ( digit * digit * digit )
temp = int(temp / 10)
if(num == sum):
return True; #Success
return False; #Failure
if __name__=="__main__":
print("Enter number: ", end="")
n = int(input())
if (isArmstrong(n)):
print("\n",n," is an armstrong number");
else:
print("\n",n," is not an armstrong number");
```

This website is made possible by displaying online advertisements to our visitors.

Please consider supporting by disabling your ad blocker.

Please consider supporting by disabling your ad blocker.