Avoid large intermediate product in LCM
This commit is contained in:
parent
c24f76781b
commit
56a029b20f
|
@ -955,7 +955,7 @@ impl Integer for BigUint {
|
||||||
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
|
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn lcm(&self, other: &BigUint) -> BigUint {
|
fn lcm(&self, other: &BigUint) -> BigUint {
|
||||||
((self * other) / self.gcd(other))
|
self / self.gcd(other) * other
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated, use `is_multiple_of` instead.
|
/// Deprecated, use `is_multiple_of` instead.
|
||||||
|
|
Loading…
Reference in New Issue