Skip to content

Commit dc409e1

Browse files
authored
Code refactor
1 parent 69f6c68 commit dc409e1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

dixon.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ def primes(B):
1515
start = isqrt(N)
1616
i = start
1717

18-
i2N = []
19-
while i<=N:
20-
i2N.append(pow(i,2,N))
21-
i+=1
22-
2318
basej2N = []
2419
for j in range(0,len(base)):
2520
basej2N.append(pow(base[j],2,N))
2621

27-
for i in range(0,len(i2N)):
22+
i2N = []
23+
while i < N:
24+
i2N = pow(i,2,N))
2825
for k in range(0,len(base)):
29-
if i2N[i] == basej2N[k]:
30-
f=gcd(start + i - base[k],N)
26+
if i2N == basej2N[k]:
27+
f=gcd(i - base[k],N)
3128
if 1 < f < N:
3229
return f,N//f
30+
i+=1
3331
return -1
3432

3533
print(dixon(int(sys.argv[1])))

0 commit comments

Comments
 (0)