euler/python/e040.py

23 lines
456 B
Python
Raw Normal View History

from lib_misc import product
def get_irrational_fraction(digits_max):
s = []
n = 1
digits = 0
while digits < digits_max:
s.append(str(n))
digits += len(str(n))
n += 1
return "".join(s)
def euler_040():
f = get_irrational_fraction(1000001)
return product(map(int, [f[10**i - 1] for i in range(7)]))
if __name__ == "__main__":
print("e040.py: " + str(euler_040()))
assert(euler_040() == 210)