diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2024-06-18 23:15:33 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2024-06-18 23:15:33 +0200 |
| commit | cca8e7138626b822729aaa749ee62b07f3217004 (patch) | |
| tree | cbded2f01f0b83190c030373320448570008ab50 /math/rho.cpp | |
| parent | 4680159f439b3b9651321e2dc9083a51fe6ce954 (diff) | |
fix rho
Diffstat (limited to 'math/rho.cpp')
| -rw-r--r-- | math/rho.cpp | 4 |
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; |
