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:
parent
bc11e57962
commit
418fd61759
1 changed files with 5 additions and 1 deletions
|
@ -100,7 +100,11 @@ fn factor(mut n: u64) -> Factors {
|
||||||
|
|
||||||
let (f, n) = table::factor(n);
|
let (f, n) = table::factor(n);
|
||||||
factors *= f;
|
factors *= f;
|
||||||
factors *= rho::factor(n);
|
|
||||||
|
if n >= table::NEXT_PRIME {
|
||||||
|
factors *= rho::factor(n);
|
||||||
|
}
|
||||||
|
|
||||||
factors
|
factors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue