1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 23:17:46 +00:00

factor::factor: Short-circuit the fallback to Pollard's rho

When the remainder is smaller than the max. entry in the table,
it is guaranteed to be prime.
This commit is contained in:
nicoo 2020-05-24 15:41:23 +02:00
parent bc11e57962
commit 418fd61759

View file

@ -100,7 +100,11 @@ fn factor(mut n: u64) -> Factors {
let (f, n) = table::factor(n);
factors *= f;
if n >= table::NEXT_PRIME {
factors *= rho::factor(n);
}
factors
}