Skip to content

Commit 56a029b

Browse files
committed
Avoid large intermediate product in LCM
1 parent c24f767 commit 56a029b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bigint/src/biguint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ impl Integer for BigUint {
955955
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
956956
#[inline]
957957
fn lcm(&self, other: &BigUint) -> BigUint {
958-
((self * other) / self.gcd(other))
958+
self / self.gcd(other) * other
959959
}
960960

961961
/// Deprecated, use `is_multiple_of` instead.

0 commit comments

Comments
 (0)