# Armstrong number in python by R4R Team

### Armstrong number -

A number is said to be an armstrong number if it's sum of digit with power of length of number is equal to the actual number.

example -
153 is an armstrong number because 1**3+5**3+3**3=153

program -

print("Enter any number")
n=int(input())
l=len(str(n))
a=n
ans=0
while(a>0):
t=a%10
ans=ans+t**l
a=int(a/10)

if ans==n:
print("It is armstrong number")
else:
print("It is not armstrong number")

output -

Enter any number
153
It is armstrong number

Enter any number
7
It is armstrong number

Enter any number
241
It is not armstrong number

-In this program, firstly we find the length of the given number. and then using while loop we split the number into the digit one by one and find the power of those digit with the length of the given number and add all this thing and at last we compare the given number to ans, if both are same then it is armstrong number otherwise it's not.

##### R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!