What is an Armstrong number?
An armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.
153 = 13+53+33
1634 =14+64+34+44
#Program to check whether a number is Armstrong or not
a= int(input("Enter the number: "))
f=a
t = 0
c = len(str(a))
while f > 0:
d = f % 10
t += d ** c
f=f // 10
if a == t:
print("The number is Armstrong")
else:
print("The number is not Armstrong")
Comments
Post a Comment