summaryrefslogtreecommitdiff
path: root/math/rho.cpp
diff options
context:
space:
mode:
authorMZuenni <michi.zuendorf@gmail.com>2024-06-28 13:47:18 +0200
committerMZuenni <michi.zuendorf@gmail.com>2024-06-28 13:47:18 +0200
commit65d2ac37862ce9d1de208a05099c281863e66256 (patch)
treed1fe1ece8790e8e8b2a8bcd3895f82477b3a0e2b /math/rho.cpp
parenta3c9198048cf465a3c01827b3667edfc99d8031c (diff)
parent366ff0a4ba0c94f5cdc2cbd4e2c991ad0b544522 (diff)
merge
Diffstat (limited to 'math/rho.cpp')
-rw-r--r--math/rho.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/math/rho.cpp b/math/rho.cpp
index 635c630..7885196 100644
--- a/math/rho.cpp
+++ b/math/rho.cpp
@@ -1,8 +1,8 @@
using lll = __int128;
ll rho(ll n) { // Findet Faktor < n, nicht unbedingt prim.
if (n % 2 == 0) return 2;
- ll x = 0, y = 0, prd = 2;
- auto f = [n](lll x){return (x * x) % n + 1;};
+ ll x = 0, y = 0, prd = 2, i = n/2 + 7;
+ auto f = [&](lll x){return (x * x + i) % n;};
for (ll t = 30, i = n/2 + 7; t % 40 || gcd(prd, n) == 1; t++) {
if (x == y) x = ++i, y = f(x);
if (ll q = (lll)prd * abs(x-y) % n; q) prd = q;