Avoid large intermediate product in LCM

This commit is contained in:
Mikhail Hogrefe 2017-12-13 21:13:57 -05:00
parent c24f76781b
commit 56a029b20f
1 changed files with 1 additions and 1 deletions

View File

@ -955,7 +955,7 @@ impl Integer for BigUint {
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
#[inline]
fn lcm(&self, other: &BigUint) -> BigUint {
((self * other) / self.gcd(other))
self / self.gcd(other) * other
}
/// Deprecated, use `is_multiple_of` instead.