Menu Close

Armstrong Number

num = int(input("Enter a number: "))

sum = 0

temp = num

while temp > 0:
   digit = temp % 10
   sum += digit ** 3 # particular number to the power of 3, (number**n)
   temp //= 10 #Floor Division, returns only the result(quotient without the floating point)

if num == sum:
   print(num,"is an Armstrong number")
else:
   print(num,"is not an Armstrong number")

'''
Output:
      Enter a number: 535
      535 is not an Armstrong number
'''

More Codes to Fcuk


Explore