Trait malachite_base::num::arithmetic::traits::CheckedLcm

source ·
pub trait CheckedLcm<RHS = Self> {
    type Output;

    // Required method
    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§

source

fn checked_lcm(self, other: RHS) -> Option<Self::Output>

Implementations on Foreign Types§

source§

impl CheckedLcm for u8

source§

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

source§

impl CheckedLcm for u16

source§

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

source§

impl CheckedLcm for u32

source§

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

source§

impl CheckedLcm for u64

source§

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

source§

impl CheckedLcm for u128

source§

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

source§

impl CheckedLcm for usize

source§

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.

§

type Output = usize

Implementors§