|
@@ -2,6 +2,7 @@
|
2
|
2
|
from math import sqrt, gcd, floor, log
|
3
|
3
|
from time import process_time
|
4
|
4
|
from psimp import trd, hund_div
|
|
5
|
+from sieve import sieve
|
5
|
6
|
|
6
|
7
|
def isqrt(n):
|
7
|
8
|
""" Find the integer square root of n via newton's method, code via
|
|
@@ -92,10 +93,15 @@ def FirstD(n):
|
92
|
93
|
# square
|
93
|
94
|
haschecked = False
|
94
|
95
|
for D in Dsequence():
|
95
|
|
- if Jacobi(D, n) == -1:
|
|
96
|
+ Jv = Jacobi(D, n)
|
|
97
|
+ # What we're looking for
|
|
98
|
+ if Jv == -1:
|
96
|
99
|
return D
|
97
|
|
- # This is supposed to be faster
|
98
|
|
- if D > 30 and not haschecked:
|
|
100
|
+ # Have found a factor
|
|
101
|
+ if Jv == 0 and abs(D) != n:
|
|
102
|
+ return 0
|
|
103
|
+ # Check for square at 13
|
|
104
|
+ if D > 10 and not haschecked:
|
99
|
105
|
if hasIntSQRT(n):
|
100
|
106
|
return 0
|
101
|
107
|
# Shouldn't fire
|
|
@@ -234,21 +240,12 @@ def StrongLucasPrime(n):
|
234
|
240
|
|
235
|
241
|
|
236
|
242
|
|
237
|
|
-#print(StrongLucasPrime(7))
|
238
|
|
-
|
239
|
|
-np = 0
|
240
|
|
-
|
241
|
|
-for i in range(10000):
|
|
243
|
+mp = 400000
|
|
244
|
+ap = sieve(mp)
|
|
245
|
+for i in range(mp):
|
|
246
|
+ iip = i in ap
|
242
|
247
|
lp = StrongLucasPrime(i)
|
243
|
|
- if lp:
|
244
|
|
- np = np + 1
|
245
|
|
- print("{}:\t{};\t{}".format(i, lp, np))
|
246
|
|
-
|
247
|
|
-print(np)
|
248
|
|
-
|
249
|
|
-print(StrongLucasPrime(5459))
|
250
|
|
-print(hund_div(5459))
|
251
|
|
-print(StrongLucasPrime(5777))
|
252
|
|
-print(hund_div(5777))
|
|
248
|
+ if iip != lp:
|
|
249
|
+ print(iip, lp, i, hund_div(i), sep='\t')
|
253
|
250
|
|
254
|
251
|
|