35 lines
860 B
Python
35 lines
860 B
Python
'''search order:
|
|
|
|
number 2**1 2**2 2**3 2**4 2**5 2**6 2**7 ...
|
|
|
|
exp 2 / 2 / 2 / 2 / 2 / 2
|
|
---/ /----/ /----/ /----/ /----/
|
|
3 / 3 / 3 / 3 / 3
|
|
---/ /----/ /----/ /----/
|
|
4 / 4 / 4 / 4
|
|
---/ /----/ /----/
|
|
5 / 5 / 5
|
|
---/ /----/
|
|
6 / 6
|
|
---/
|
|
7
|
|
'''
|
|
|
|
def test(find, base, exp, flag):
|
|
num = base ** exp
|
|
if sum(map(lambda x: int(x), str(num))) == base:
|
|
find.append(num)
|
|
|
|
def expand(limit):
|
|
find = []
|
|
exp = 3
|
|
while len(find) < limit:
|
|
for e in range(2, exp):
|
|
start = 2 ** (exp - e)
|
|
for num in range(start, 2 * start):
|
|
test(find, num, e, exp)
|
|
exp += 1
|
|
return find
|
|
|
|
print(expand(30))
|