2019-07-18 20:23:44 +02:00
|
|
|
from lib_misc import get_digit_count
|
|
|
|
|
|
|
|
|
|
|
|
def get_n_digit_positive_integers(n):
|
|
|
|
r = []
|
|
|
|
i = 1
|
|
|
|
while True:
|
|
|
|
if get_digit_count(i ** n) == n:
|
|
|
|
r.append(i ** n)
|
|
|
|
if get_digit_count(i ** n) > n:
|
|
|
|
return r
|
|
|
|
i += 1
|
|
|
|
|
2019-07-18 03:29:59 +02:00
|
|
|
|
|
|
|
def euler_063():
|
2019-07-18 20:23:44 +02:00
|
|
|
s = sum([len(get_n_digit_positive_integers(n)) for n in range(1, 1000)])
|
|
|
|
return s
|
2019-07-18 03:29:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print("e063.py: " + str(euler_063()))
|
2019-07-18 20:23:44 +02:00
|
|
|
assert(euler_063() == 49)
|