Problem

An irrational decimal fraction is created by concatenating the positive integers:

\[0.123456789101112131415161718192021...\]

It can be seen that the 12th digit of the fractional part is 1.

If $d_n$ represents the nth digit of the fractional part, find the value of the following expression.

\[d_1\times d_{10}\times d_{100}\times d_{1000}\times d_{10000}\times d_{100000}\times d_{1000000}\]

Python Solution

This was coded in Python using the Sage Notebook (for speed). The idea is to concatenate the string representations of increasing integers into a single string, turn that string into a list with the appropriate index range, and take the appropriate product from within that list. I use the range 400000 to form the string, guessing (correctly) that this would provide enough digits in the resulting string/list.

import time
 
start = time.time()
 
s = ""
for i in range(400000):
    s += str(i)
d = list(s)
n = prod([ZZ(d[10**i]) for i in range(7)])
 
elapsed = time.time() - start
 
print "result %s found in %s seconds" % (n, elapsed)

When executed, we get the following result.

result 210 found in 0.369875907898 seconds