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 dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
Naive solution.
Directly get the ith digit by calculation.
from functools import reduce
from operator import mul
from math import ceil
def get_digit(ith):
start = 0
for digit_number, total in enumerate(map(lambda i: pow(10, i) * 9, range(6)), 1):
if ith > total * digit_number:
start += total
ith -= total * digit_number
else:
break
k, r = ceil(ith / digit_number), (ith-1) % digit_number
return int(str(start + k)[r])
get_digit(11)
get_digit(12)
get_digit(1)
def solve():
return reduce(mul, map(get_digit, map(lambda i: pow(10, i), range(7))), 1)
solve()