mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 23:17:46 +00:00
factor::Factors: Generalise invariant check (from prime() to add())
This commit is contained in:
parent
2d2b6faab4
commit
f1d1cb80e4
1 changed files with 1 additions and 1 deletions
|
@ -23,13 +23,13 @@ impl Factors {
|
|||
}
|
||||
|
||||
pub fn prime(p: u64) -> Factors {
|
||||
debug_assert!(miller_rabin::is_prime(p));
|
||||
let mut f = Factors::one();
|
||||
f.push(p);
|
||||
f
|
||||
}
|
||||
|
||||
pub fn add(&mut self, prime: u64, exp: u8) {
|
||||
debug_assert!(miller_rabin::is_prime(prime));
|
||||
debug_assert!(exp > 0);
|
||||
let n = *self.f.get(&prime).unwrap_or(&0);
|
||||
self.f.insert(prime, exp + n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue