Skip to content

Commit

Permalink
vary f to not hang on 124376107291
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukundan314 committed Nov 25, 2024
1 parent bff505b commit ea0c725
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyrival/algebra/factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def pollard_rho(n):
break
else:
for i in range(2, n):
x, y = i, (i * i + 1) % n
x, y = i, (i * i + i) % n
f = gcd(abs(x - y), n)
while f == 1:
x, y = (x * x + 1) % n, (y * y + 1) % n
y = (y * y + 1) % n
x, y = (x * x + i) % n, (y * y + i) % n
y = (y * y + i) % n
f = gcd(abs(x - y), n)
if f != n:
return f
Expand Down

0 comments on commit ea0c725

Please sign in to comment.