# Python function to check ArmStrong Number

In this example, We are going to define a user-defined function to check whether the entered number is Armstrong number or not.

A number is known as Armstrong’s number if the sum of the cube root of each digit of this number regenerates the same number again.

## Python function to check Armstrong Number

##
def armstrong(n):
m = n
sum = 0
while(n != 0):
rem = n % 10
sum += rem**3
n = n//10
return True if sum == m else False

Implementation of armstrong function in a Python Program

if __name__ == "__main__": n = int(input('Enter any number :')) print('ArmStrong Number ' if(armstrong(n)) else 'Not a Arm Strong Number ')

Hence the whole Python program is

def armstrong(n): m = n sum = 0 while(n != 0): rem = n % 10 sum += rem**3 n = n//10 return True if sum == m else False if __name__ == "__main__": n = int(input('Enter any number :')) print('ArmStrong Number ' if(armstrong(n)) else 'Not a ArmStrong Number ')

Output of the above Program is

Enter any number:6 Not a ArmStrong Number Enter any number :153 ArmStrong Number