# Trait malachite_base::num::arithmetic::traits::Gcd

pub trait Gcd<RHS = Self> {
type Output;

// Required method
fn gcd(self, other: RHS) -> Self::Output;
}
Expand description

Calculates the GCD (greatest common divisor) of two numbers.

source

source

## Implementations on Foreign Types§

source§

### impl Gcd for u8

source§

#### fn gcd(self, other: u8) -> u8

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§

source§

### impl Gcd for u16

source§

#### fn gcd(self, other: u16) -> u16

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§

source§

### impl Gcd for u32

source§

#### fn gcd(self, other: u32) -> u32

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§

source§

### impl Gcd for u64

source§

#### fn gcd(self, other: u64) -> u64

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§

source§

### impl Gcd for u128

source§

#### fn gcd(self, other: u128) -> u128

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§

source§

### impl Gcd for usize

source§

#### fn gcd(self, other: usize) -> usize

Computes the GCD (greatest common divisor) of two numbers.

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

$$f(x, y) = \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()).

See here.

§