## 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

1. Chris Scheurer
Posted October 12, 2013 at 10:31 |

I found a recursive algorithm to calculate the nth digit of the Champernowne’s constant:
 int digit(int n, int d) { stringstream ss; ss<>n; return n; }

 

int nummer(int n, int p=1,int diff=0 ) { if (n>((pow(10,p)-pow(10,p-1))*p)) { n-=(pow(10,p)-pow(10,p-1))*p; nummer(n,p+1,pow(10,p)-1); } else return digit((n+p-1)/p+diff,(n+p-1)%p); } 

2. Chris Scheurer
Posted October 12, 2013 at 10:33 |

Hm, copy’n'paste didn’t really work

3. Posted May 22, 2014 at 17:42 |

Sale in hot of Nike Elite Cardinals lights out jerseys, we’ll provide best products for you. free shipping & 365 day returns.

4. Reo
Posted May 10, 2016 at 08:20 |

Isn’t 185185 enough for the range? You’ll get 1000005 digits after 0. with this.