From 56a029b20f0e63d0b518169d22d1915486978d8a Mon Sep 17 00:00:00 2001 From: Mikhail Hogrefe Date: Wed, 13 Dec 2017 21:13:57 -0500 Subject: [PATCH] Avoid large intermediate product in LCM --- bigint/src/biguint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigint/src/biguint.rs b/bigint/src/biguint.rs index 439332f..df551ba 100644 --- a/bigint/src/biguint.rs +++ b/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.