In 1752 Goldbach conjectured that every odd integer can be written in the form p + 2a^2, where p is unity or a prime and a is allowed to be zero.
This conjecture is found to be false - there are only two known composite exceptions, 5777 (=53*109) being one of them.
Please find the other, it is below 99,999.
5777 (given)
5993 (the other one)
from
DefDbl A-Z
Dim wd(10) As String, w As String, sz, crlf$
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
For n = 3 To 99999 Step 2
If prmdiv(n) < n Then
p = 1: found = 0
Do
q = (n - p) / 2
If q = Int(q) Then
a = Int(Sqr(q) + 0.5)
If a * a = q Then
found = 1: Exit Do
End If
End If
p = nxtprm(p)
Loop Until p > n
If found = 0 Then Text1.Text = Text1.Text & n & crlf
End If
Next
End Sub
Function prm(i)
Dim p As Long
Open "17-bit primes.bin" For Random As #111 Len = 4
Get #111, i, p
prm = p
Close 111
End Function
Function prmdiv(num)
Dim n, dv, q
If num = 1 Then prmdiv = 1: Exit Function
n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
If limit <> Int(limit) Then limit = Int(limit + 1)
dv = 2: GoSub DivideIt
dv = 3: GoSub DivideIt
dv = 5: GoSub DivideIt
dv = 7
Do Until dv > limit
GoSub DivideIt: dv = dv + 4 '11
GoSub DivideIt: dv = dv + 2 '13
GoSub DivideIt: dv = dv + 4 '17
GoSub DivideIt: dv = dv + 2 '19
GoSub DivideIt: dv = dv + 4 '23
GoSub DivideIt: dv = dv + 6 '29
GoSub DivideIt: dv = dv + 2 '31
GoSub DivideIt: dv = dv + 6 '37
Loop
If n > 1 Then prmdiv = n
Exit Function
DivideIt:
Do
q = Int(n / dv)
If q * dv = n And n > 0 Then
prmdiv = dv: Exit Function
Else
Exit Do
End If
Loop
Return
End Function
Function nxtprm(x)
Dim n
n = x + 1
While prmdiv(n) < n
n = n + 1
Wend
nxtprm = n
End Function
|
Posted by Charlie
on 2015-03-03 13:24:17 |