Given
P=(a/b+c/d)*(e/f+g/h) ,
where a,b,c.., ...h are 8 distinct positive integers, all below 25 and all fractions are proper fractions,
find the
highest and the lowest values of
P.
Rem: P&P solution preferred.
(In reply to
Guesses by Jer)
Dim crlf$, used(25)
Private Sub Form_Load()
ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
mini = 0.05: maxi = 3.25
For a = 1 To 25
If used(a) = 0 Then
used(a) = 1
For b = a + 1 To 25
If used(b) = 0 Then
used(b) = 1
ab = a / b
For c = a + 1 To 25
If used(c) = 0 Then
used(c) = 1
For e = a + 1 To 25
If used(e) = 0 Then
used(e) = 1
For d = c + 1 To 25
If used(d) = 0 Then
used(d) = 1
abcd = ab + c / d
For f = e + 1 To 25
If used(f) = 0 Then
used(f) = 1
ef = e / f
For g = e + 1 To 25
If used(g) = 0 Then
used(g) = 1
For h = g + 1 To 25
If used(h) = 0 Then
used(h) = 1
abcdefgh = abcd * (ef + g / h)
rounded = Int(abcdefgh + 0.5)
If abcdefgh < mini Then
Text1.Text = Text1.Text & Str(a) & Str(b) & Str(c) & Str(d) & Str(e) & Str(f) & Str(g) & Str(h) & Str(abcdefgh) & crlf
mini = abcdefgh
DoEvents
End If
If abcdefgh > maxi Then
Text1.Text = Text1.Text & Str(a) & Str(b) & Str(c) & Str(d) & Str(e) & Str(f) & Str(g) & Str(h) & Str(abcdefgh) & crlf
maxi = abcdefgh
DoEvents
End If
used(h) = 0
End If
Next
used(g) = 0
End If
Next
used(f) = 0
End If
Next
used(d) = 0
End If
Next
used(e) = 0
End If
Next
used(c) = 0
End If
Next
used(b) = 0
End If
Next
used(a) = 0
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
finds
...
1 22 2 25 3 23 4 24 3.72727272727273E-02
so the minimum is (1/22 + 2/25) * (3/23 + 4/24) = 0.03727272...
...
18 19 24 25 20 21 22 23 3.64098071265119
and the maximum is (18/19 + 24/25) * (20/21 + 22/23) = 3.64098071265119.
|
Posted by Charlie
on 2014-09-22 12:22:25 |