Преглед изворни кода

Avoid large intermediate product in LCM

Mikhail Hogrefe пре 7 година
родитељ
комит
56a029b20f
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      bigint/src/biguint.rs

+ 1 - 1
bigint/src/biguint.rs

@@ -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.