Champernowne’s constant
Problem 40
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
Answer:
210
Completed on Fri, 17 Jul 2015, 18:25
Go to the thread for problem 40 in the forum.
python code:
__author__ = ‘zhengyi‘
def funcNum(x):
k=0
while x>0:
k+=1
x=x//10
return k
def func(d,c,k):
temp=funcNum(c)
for i in range(0,d-k):
c=c//10
return c%10
c=1
d=1
r=1
index=[pow(10,i) for i in range(1,7)]
while len(index)>0:
c+=1
d+=funcNum(c)
if d==index[0]:
r*=c%10
del index[0]
continue
else:
if d>index[0]:
r=r*func(d,c,index[0])
del index[0]
print(r)
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-12-03 02:38:41