Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def armstr_checker(n):
- sum=0
- count = len(str(n)) #finding no of digits to be used as power
- num1 = n #temp variable to store value of n
- while num1 > 0:
- last_digit = num1 % 10
- sum = sum + last_digit**count
- num1 = num1 // 10
- if sum == n:
- return True
- return False
- try:
- num2 = int(input("enter an integer :"))
- except ValueError:
- print("invalid input")
- num2 = int(input("enter an integer :"))
- list =[]
- for i in range(num2):
- if armstr_checker(i) == True:
- list.append(i)
- print(list)
Advertisement
Add Comment
Please, Sign In to add comment