Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Write a program to input a number and check it is an amstrong number or not'''
- '''Amstrong number means sum of the cubes of its digit must be same as the original number'''
- '''Eg: 143 = 3^3 + 4^3 + 1^3 != 143'''
- '''Eg: 153 = 3^3 + 5^3 + 1^3'''
- num = int(input('The number is: ',))
- sum = 0
- a = num
- while a > 0:
- digit = a%10
- sum = sum + digit**3
- a = a//10
- if num == sum:
- print('The number', sum, 'is an Amstrong number')
- else:
- print('The number', sum, 'is not an Amstrong number')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement