MENU
Question -

Write a Python program to check if a given number is an Armstrong number.



Answer -

sum = 0
n = int (raw_input (“Enter number”)
n1 = n
while (n > 0):
a = n%10
sum = sum + (a * a * a)
n = n/10
if (sum ==n1):
print n, “is an Armstrong number”
else:
print n, “is not an Armstrong number”

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×