Python program to check Armstrong Number or not


Write a program in python to input number and check given number is Armstrong number or not  


Note- Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

--------------------------------------------------------

number=int(input("Enter any Number : "))
sum=0
tmp=number
while number>0:
    digit=(number%10)
    sum=sum+digit**3
    number=number//10
if sum==tmp:
    print(tmp, " is a Armstrong Number")
else:
    print(tmp, " is not a Armstrong Number")

--------------------------------------------------------

Output:-

Enter any Number : 370

370 is a Armstrong Number

----

Enter any Number : 457

457 is not a Armstrong Number

Post a Comment

0 Comments