def myfun(): lower=int(input("Enter the lower limit of the interval: ")) upper=int(input("Enter the upper limit of the interval: ")) for num in range(lower,upper+1): order=len(str(num)) temp_num=num sum=0 while(temp_num>0): digit=temp_num % 10 sum=sum + digit ** order temp_num=temp_num // 10 if(num==sum): print(num) if __name__=="__main__": myfun()
Enter the lower limit of the interval: 10
Enter the upper limit of the interval: 10000
153
370
371
407
1634
8208
9474