Python Program to Check Armstrong Number


SUBMITTED BY: Bun

DATE: Feb. 7, 2016, 9:50 p.m.

FORMAT: Text only

SIZE: 303 Bytes

HITS: 1704

  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