Seeking "bad" number

The so-called "bad" number, which refers to the digits of the 5 th power is equal to the number itself. All positive integer programming output does not exceed the length of n bits in the "bad" number. For example: 4151 = 1

Input formats:

An integer n (1 <= n <= 6)

Output formats:

Each line of a "severe" number

Sample input:

4
 

Sample output:

1
4150
4151
n=int(input())
for i in range(1,10**n):
    j=i
    sum=0
    if i>1314520:
        break
    while i!=0:
        a=i%10
        i=i//10
        sum+=a**5
    if sum==j:
        print(j)

  

Guess you like

Origin www.cnblogs.com/SkystarX/p/12334049.html