Python code to check armstrong number


SUBMITTED BY: Bun

DATE: Feb. 7, 2016, 10:10 p.m.

FORMAT: Python 3

SIZE: 299 Bytes

HITS: 1495

  1. #Python Program to check Armstrong Number:
  2. number = int(input("Please enter a number: "))
  3. sum = 0
  4. temp = num
  5. while temp > 0:
  6. dgt = temp % 10
  7. sum += dgt ** 3
  8. temp //= 10
  9. if num == sum:
  10. print(num,"it is an Armstrong number")
  11. else:
  12. print(num,"it is not an Armstrong number")

comments powered by Disqus