Trait malachite_base::num::arithmetic::traits::CheckedLcm
source · [−]pub trait CheckedLcm<RHS = Self> {
type Output;
fn checked_lcm(self, other: RHS) -> Option<Self::Output>;
}
Expand description
Calculates the LCM (least common multiple) of two numbers, returning None
if the result is
not representable.
Required Associated Types
Required Methods
fn checked_lcm(self, other: RHS) -> Option<Self::Output>
Implementations on Foreign Types
sourceimpl CheckedLcm<u8> for u8
impl CheckedLcm<u8> for u8
sourcefn checked_lcm(self, other: u8) -> Option<u8>
fn checked_lcm(self, other: u8) -> Option<u8>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.
type Output = u8
sourceimpl CheckedLcm<u16> for u16
impl CheckedLcm<u16> for u16
sourcefn checked_lcm(self, other: u16) -> Option<u16>
fn checked_lcm(self, other: u16) -> Option<u16>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.
type Output = u16
sourceimpl CheckedLcm<u32> for u32
impl CheckedLcm<u32> for u32
sourcefn checked_lcm(self, other: u32) -> Option<u32>
fn checked_lcm(self, other: u32) -> Option<u32>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.
type Output = u32
sourceimpl CheckedLcm<u64> for u64
impl CheckedLcm<u64> for u64
sourcefn checked_lcm(self, other: u64) -> Option<u64>
fn checked_lcm(self, other: u64) -> Option<u64>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.
type Output = u64
sourceimpl CheckedLcm<u128> for u128
impl CheckedLcm<u128> for u128
sourcefn checked_lcm(self, other: u128) -> Option<u128>
fn checked_lcm(self, other: u128) -> Option<u128>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.
type Output = u128
sourceimpl CheckedLcm<usize> for usize
impl CheckedLcm<usize> for usize
sourcefn checked_lcm(self, other: usize) -> Option<usize>
fn checked_lcm(self, other: usize) -> Option<usize>
Computes the LCM (least common multiple) of two numbers, returning None
if the
result is too large to represent.
$$
f(x, y) = \begin{cases}
\operatorname{Some}(\operatorname{lcm}(x, y)) &
\text{if} \quad \operatorname{lcm}(x, y) < 2^W, \\
\operatorname{None} & \text{if} \quad \operatorname{lcm}(x, y) \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
max(self.significant_bits(), other.significant_bits())
.
Examples
See here.