当正确接近时,这并不难.
例如,假设您要查找以123开始并以k非零数字结尾的所有整数的倒数之和(即最左边的数字).显然有9k这样的整数,这些整数的倒数在1 /(124 * 10k)… 1 /(123 * 10k)的范围内.因此,所有这些整数的倒数之和受(9/10)k / 124和(9/10)k / 123的限制.
为了找到以123开始的所有倒数之和的界限,必须将每个k> = 0的上限加起来.这是几何系列,因此可以推导出以123开始的整数倒数之和由10 *(9/10)k / 124和10 *(9/10)k / 123限定.
当然,相同的方法可以应用于最左边数字的任何组合.
我们在左侧检查的数字越多,结果就越准确.
这是python中这种方法的实现:
def approx(t,k):
"""Returns a lower bound and an upper bound on the sum of reciprocals of
positive integers starting with t not containing 0 in its decimal
representation.
k is the recursion depth of the search, i.e. we append k more digits
to t, before approximating the sum. A larger k gives more accurate
results, but takes longer."""
if k == 0:
return 10.0/(t+1), 10.0/t
else:
if t > 0:
low, up = 1.0/t, 1.0/t
else:
low, up = 0, 0
for i in range(10*t+1, 10*t+10):
l,u = approx(i, k-1)
low += l
up += u
return low, up
例如,调用约(0,8)给出下限和上限:
23.103447707 ……和23.103448107 ….
这与OP提出的索赔23.10345很接近.
有些方法可以更快地收敛到所讨论的总和,但它们需要更多的数学运算.
可以在here找到更好的近似值.问题的推广是Kempner series.