summaryrefslogtreecommitdiff
path: root/math/rho.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/rho.cpp')
-rw-r--r--math/rho.cpp19
1 files changed, 0 insertions, 19 deletions
diff --git a/math/rho.cpp b/math/rho.cpp
deleted file mode 100644
index 7885196..0000000
--- a/math/rho.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-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, 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;
- x = f(x); y = f(f(y));
- }
- return gcd(prd, n);
-}
-
-void factor(ll n, map<ll, int>& facts) {
- if (n == 1) return;
- if (isPrime(n)) {facts[n]++; return;}
- ll f = rho(n);
- factor(n / f, facts); factor(f, facts);
-}