A certain set of positive integers
(a,b,c) causes the sum of their reversals (i.e. S=1/a+1/b+1/c) to be the closest to 1/2 without equaling or exceeding it.
Find S.
Explain your method.
First, to explain the method, which makes this answer be that to an Algorithms puzzle:
WLOG, let a < b < c so their reciprocals are in descending order.
Find the smallest a that does not cause 1/a to equal or exceed 1/2, and do the remainder of the calculations described below for this a and each a that's larger than this up through the first one where 1/a + 1/(a+1) + 1/(a+2) is less than 1/2.
For each of those a's, find the smallest b that does not cause 1/a + 1/b to equal or exceed 1/2, and do the next paragraph for each b from this value through the first one where 1/a + 1/b + 1/(b+1) is less than 1/2.
For each such pair (a,b) find the smallest c that does not cause 1/a + 1/b + 1/c to equal or exceed 1/2 (this should be b+1).
Choose the largest among all the 1/a + 1/b + 1/c.
So:
1/3 uses a=3 and the smallest b is 7 that results in the sum of those reciprocals to be smaller than 1/2: 1/3 + 1/7 = 10/21.
The smallest c that allows fitting is 42, but that results in 1/2 exactly: 1/3 + 1/7 + 1/42 = 1/2, so the next c, 43 gives an answer of 1/3 + 1/7 + 1/43 ~= 0.499446290143965
This is too tedious to continue manually, so:
For a = 1 To 11
Text6.Text = Text6.Text & a & crlf
If 1 / a < 1 / 2 Then
b = a + 1
Do
Text6.Text = Text6.Text & a & Str(b) & crlf
If 1 / a + 1 / b < 1 / 2 Then
c = b + 1
Do
If 1 / a + 1 / b + 1 / c <= 1 / 2 Then
Text6.Text = Text6.Text & a & Str(b) & Str(c)
Text6.Text = Text6.Text & " " & 1 / a + 1 / b + 1 / c & crlf
DoEvents
End If
If 1 / a + 1 / b + 1 / c < 1 / 2 Then Exit Do
c = c + 1
Loop
DoEvents
End If
b = b + 1
DoEvents
Loop Until 1 / a + 1 / b + 1 / (b + 1) < 1 / 2
DoEvents
End If
If 1 / a + 1 / (a + 1) + 1 / (a + 2) < 1 / 2 Then Exit For
Next
results in:
a b c 1/a + 1/b + 1/c
2
3
3 4
3 5
3 6
3 7
3 7 42 0.5
3 7 43 0.499446290143965
3 8
3 8 24 0.5
3 8 25 0.498333333333333
3 9
3 9 18 0.5
3 9 19 0.497076023391813
3 10
3 10 15 0.5
3 10 16 0.495833333333333
3 11
3 11 14 0.495670995670996
4
4 5
4 5 20 0.5
4 5 21 0.497619047619048
4 6
4 6 12 0.5
4 6 13 0.493589743589744
4 7
4 7 10 0.492857142857143
5
5 6
5 6 8 0.491666666666667
6
6 7
6 7 8 0.43452380952381
and indeed
1/3 + 1/7 +1/43 ~= 0.499446290143965, the first arrived at, is the largest without going over 0.5.
The exact value is 451/903.
|
Posted by Charlie
on 2020-05-15 09:46:18 |