From ea0c7257dfbeb67a07b54abd7370bc22ff4ef8b4 Mon Sep 17 00:00:00 2001 From: Mukundan314 Date: Mon, 25 Nov 2024 11:40:26 +0530 Subject: [PATCH] vary f to not hang on 124376107291 --- pyrival/algebra/factors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyrival/algebra/factors.py b/pyrival/algebra/factors.py index 7666e63..76041ba 100644 --- a/pyrival/algebra/factors.py +++ b/pyrival/algebra/factors.py @@ -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