Solution of the Week #367 - Come Close But Don't Touch

It turns out the best approach is a kind of ‘greedy’ algorithm, where each unit fraction is the most it can be, given how much is left of the 1 we are trying to almost fill. This is easily calculated: if there is 1/n remaining, the next biggest unit fraction will be 1/(n+1).

So the first unit fraction will be 1/2, leaving 1/2.

Therefore the second unit fraction is 1/3, leaving 1/6.

Next is 1/7, leaving 1/42.

Next is 1/43, leaving 1/1806.

Finally we add 1/1807, leaving us just 1/3263442 short of the 1.

So our final sum comes to 3263441/3263442 = 0.9999996936…