diff --git a/src/utils/gcd.rs b/src/utils/gcd.rs index 50cd0ba..6a1b9a3 100644 --- a/src/utils/gcd.rs +++ b/src/utils/gcd.rs @@ -12,11 +12,11 @@ where /// NOTE: Exists for the internal LCM implementation. #[deprecated(note = "use crate::utils::gcd::Gcd::gcd() instead.")] #[must_use] - fn __gcd_no_zero_check(mut self, mut other: Self) -> Self { + fn __gcd_no_zero_check(mut self, mut other: Self) -> u32 { let k = { let i = self.trailing_zeros(); let j = other.trailing_zeros(); - i.min(j) as usize + i.min(j) }; while !other.is_zero() { @@ -27,13 +27,13 @@ where other >>= other.trailing_zeros(); } - self << k + (self.to_u32().unwrap()) << k } - fn gcd(self, other: Self) -> Self { + fn gcd(self, other: Self) -> u32 { if self.is_zero() { - return self; + return self.to_u32().unwrap(); } else if other.is_zero() { - return other; + return other.to_u32().unwrap(); } #[allow(deprecated)] self.__gcd_no_zero_check(other) diff --git a/src/utils/lcm.rs b/src/utils/lcm.rs index 3dc914e..18cbe7e 100644 --- a/src/utils/lcm.rs +++ b/src/utils/lcm.rs @@ -1,15 +1,15 @@ use crate::utils::gcd::Gcd; pub trait Lcm: Gcd { - fn lcm(self, other: Self) -> Self { + fn lcm(self, other: Self) -> u32 { if self.is_zero() { - return self; + return self.to_u32().unwrap(); } else if other.is_zero() { - return other; + return other.to_u32().unwrap(); } #[allow(deprecated)] // Internal call to save second zero checks. { - (self * other) / (self.__gcd_no_zero_check(other)) + (self * other).to_u32().unwrap() / (self.__gcd_no_zero_check(other)) } } }