summaryrefslogtreecommitdiff
path: root/content/math/rho.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 17:48:10 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 18:01:53 +0100
commite55df069a8f83b2c0c2b56c035f49e89516cdaaa (patch)
treedd6767e3fc6ac8532661dc75886a3056804d1d46 /content/math/rho.cpp
parent72bd993483453ed8ebc462f1a33385cd355d486f (diff)
minor fixes, let code breathe where possible
Diffstat (limited to 'content/math/rho.cpp')
-rw-r--r--content/math/rho.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/content/math/rho.cpp b/content/math/rho.cpp
index ad640cd..c7f7a70 100644
--- a/content/math/rho.cpp
+++ b/content/math/rho.cpp
@@ -2,7 +2,7 @@ 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 c){return (c * c + i) % n;};
+ auto f = [&](lll c) { return (c * c + i) % n; };
for (ll t = 30; 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;
@@ -13,7 +13,7 @@ ll rho(ll n) { // Findet Faktor < n, nicht unbedingt prim.
void factor(ll n, map<ll, int>& facts) {
if (n == 1) return;
- if (isPrime(n)) {facts[n]++; return;}
+ if (isPrime(n)) { facts[n]++; return; }
ll f = rho(n);
factor(n / f, facts); factor(f, facts);
}