We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e31635 commit 4024628Copy full SHA for 4024628
dixon.py
@@ -0,0 +1,37 @@
1
+from gmpy2 import isqrt,gcd,next_prime
2
+import sys
3
+
4
+def dixon(N,B=100):
5
6
+ tmp = []
7
+ pairs = []
8
9
+ def primes(B):
10
+ p = 2
11
+ tmp = [p]
12
+ while p < B-1:
13
+ p = next_prime(p)
14
+ tmp.append(p)
15
+ return tmp
16
17
+ base = primes(B)
18
19
+ start = isqrt(N)
20
+ i = start
21
+ while i<=N:
22
+ for j in range(len(base)):
23
+ l = pow(i,2, N)
24
+ r = pow(base[j],2,N)
25
+ if l == r:
26
+ pairs.append([i,base[j]])
27
+ print(pairs)
28
+ i+=1
29
30
+ for i in range(len(pairs)):
31
+ x = pairs[i][0]
32
+ y = pairs[i][1]
33
+ tmp.append(gcd(x-y,N))
34
35
36
37
+print(dixon(int(sys.argv[1])))
0 commit comments