Saturday, 29 October 2016

check armstrong number or not...


# Python program to check if the number provided by the user is an Armstrong number or not...


n = int(input("Enter a number: "))
sum = 0
t = n
while t > 0:
   r = t % 10
   sum += r ** 3
   t //= 10
if n == sum:
   print(n,"is an Armstrong number")
else:
   print(n,"is not an Armstrong number")




No comments:

Post a Comment