52 lines
1.3 KiB
Text
52 lines
1.3 KiB
Text
' version 12-08-2017
|
|
' compile with: fbc -s console
|
|
|
|
#Define max 2200
|
|
|
|
Dim As UInteger l, m, n, l2, l2m2
|
|
Dim As UInteger limit = max * 4 \ 15
|
|
Dim As UInteger max2 = limit * limit * 2
|
|
ReDim As Ubyte list_1(max2), list_2(max2 +1)
|
|
|
|
' prime sieve, list_2(l) contains a 0 if l = prime
|
|
For l = 4 To max2 Step 2
|
|
list_1(l) = 1
|
|
Next
|
|
For l = 3 To max2 Step 2
|
|
If list_1(l) = 0 Then
|
|
For m = l * l To max2 Step l * 2
|
|
list_1(m) = 1
|
|
Next
|
|
End If
|
|
Next
|
|
|
|
' we do not need a and b (a and b are even, l = a \ 2, m = b \ 2)
|
|
' we only need to find d
|
|
For l = 1 To limit
|
|
l2 = l * l
|
|
For m = l To limit
|
|
l2m2 = l2 + m * m
|
|
list_2(l2m2 +1) = 1
|
|
' if l2m2 is a prime, no other factors exits
|
|
If list_1(l2m2) = 0 Then Continue For
|
|
' find possible factors of l2m2
|
|
' if l2m2 is odd, we need only to check the odd divisors
|
|
For n = 2 + (l2m2 And 1) To Fix(Sqr(l2m2 -1)) Step 1 + (l2m2 And 1)
|
|
If l2m2 Mod n = 0 Then
|
|
' set list_2(x) to 1 if solution is found
|
|
list_2(l2m2 \ n + n) = 1
|
|
End If
|
|
Next
|
|
Next
|
|
Next
|
|
|
|
For l = 1 To max
|
|
If list_2(l) = 0 Then Print l; " ";
|
|
Next
|
|
Print
|
|
|
|
' empty keyboard buffer
|
|
While InKey <> "" : Wend
|
|
Print : Print "hit any key to end program"
|
|
Sleep
|
|
End
|