Trait malachite_base::num::arithmetic::traits::GcdAssign

source ·
pub trait GcdAssign<RHS = Self> {
    // Required method
    fn gcd_assign(&mut self, other: RHS);
}
Expand description

Replaces a number with the GCD (greatest common divisor) of it and another number.

Required Methods§

source

fn gcd_assign(&mut self, other: RHS)

Implementations on Foreign Types§

source§

impl GcdAssign for u8

source§

fn gcd_assign(&mut self, other: u8)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

source§

impl GcdAssign for u16

source§

fn gcd_assign(&mut self, other: u16)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

source§

impl GcdAssign for u32

source§

fn gcd_assign(&mut self, other: u32)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

source§

impl GcdAssign for u64

source§

fn gcd_assign(&mut self, other: u64)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

source§

impl GcdAssign for u128

source§

fn gcd_assign(&mut self, other: u128)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

source§

impl GcdAssign for usize

source§

fn gcd_assign(&mut self, other: usize)

Replaces another with the GCD (greatest common divisor) of it and another number.

The GCD of 0 and $n$, for any $n$, is 0. In particular, $\gcd(0, 0) = 0$, which makes sense if we interpret “greatest” to mean “greatest by the divisibility order”.

$$ x \gets \gcd(x, y). $$

§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.

Implementors§