Skip to content

Commit ea33fd8

Browse files
committed
update pollard rho in primitive root
1 parent ea0c725 commit ea33fd8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyrival/algebra/primitive_root.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def pollard_rho(n):
4040
break
4141
else:
4242
for i in range(2, n):
43-
x, y = i, (i * i + 1) % n
43+
x, y = i, (i * i + i) % n
4444
f = gcd(abs(x - y), n)
4545
while f == 1:
46-
x, y = (x * x + 1) % n, (y * y + 1) % n
47-
y = (y * y + 1) % n
46+
x, y = (x * x + i) % n, (y * y + i) % n
47+
y = (y * y + i) % n
4848
f = gcd(abs(x - y), n)
4949
if f != n:
5050
return f

0 commit comments

Comments
 (0)