Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 646 Bytes

40. Champernowne's constant.md

File metadata and controls

24 lines (16 loc) · 646 Bytes

Question

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

0.123456789101112131415161718192021...

If d(n) represents the nth digit of the fractional part, find the value of the following expression

d(1) × d(10) × d(100) × d(1000) × d(10000) × d(100000) × d(1000000)

Solution

from operator import mul
from functools import reduce

def p40():
    s = ''.join(str(x) for x in range(1000000)) # trial and error unitl no IndexError
    return reduce(mul, [int(s[10 ** i]) for i in range(7)])

Answer

210