DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
l10 = Log(10)
For tot = 3 To 9999999
For x = 1 To tot / 2
DoEvents
y = tot - x
lpwr = Log(x) * y / l10
If lpwr < 16 Then
p = Int(10 ^ lpwr + 0.5)
g = gcd(x, y)
lcm = x * y / g
If p + g = 2 * (lcm - 1) Then
Text1.Text = Text1.Text & x & Str(y) & " " & g & Str(lcm - 1) & Str(p) & crlf
End If
End If
h = y: y = x: x = h
lpwr = Log(x) * y / l10
If lpwr < 16 Then
p = Int(10 ^ lpwr + 0.5)
g = gcd(x, y)
lcm = x * y / g
If p + g = 2 * (lcm - 1) Then
Text1.Text = Text1.Text & x & Str(y) & " " & g & Str(lcm - 1) & Str(p) & crlf
End If
Else
Exit For
End If
h = y: y = x: x = h
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function gcd(a, b)
x = a: y = b
Do
q = Int(x / y)
z = x - q * y
x = y: y = z
Loop Until z = 0
gcd = x
End Function
finds only
x y sequence
1 2 1 1 1
3 1 1 2 3
3 2 1 5 9
|
Posted by Charlie
on 2016-04-29 11:30:46 |