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

source · ```
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.

## Required Associated Types§

## Required Methods§

## Implementations on Foreign Types§

source§### impl Gcd for u8

### impl Gcd for u8

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

#### 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())`

.

##### §Examples

See here.

#### type Output = u8

source§### impl Gcd for u16

### impl Gcd for u16

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

#### 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())`

.

##### §Examples

See here.

#### type Output = u16

source§### impl Gcd for u32

### impl Gcd for u32

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

#### 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())`

.

##### §Examples

See here.

#### type Output = u32

source§### impl Gcd for u64

### impl Gcd for u64

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

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

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

$$ f(x, y) = \gcd(x, y). $$

##### §Worst-case complexity

$T(n) = O(n^2)$

$M(n) = O(n)$

`max(self.significant_bits(), other.significant_bits())`

.

##### §Examples

See here.

#### type Output = u64

source§### impl Gcd for u128

### impl Gcd for u128

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

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

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

$$ f(x, y) = \gcd(x, y). $$

##### §Worst-case complexity

$T(n) = O(n^2)$

$M(n) = O(n)$

`max(self.significant_bits(), other.significant_bits())`

.

##### §Examples

See here.

#### type Output = u128

source§### impl Gcd for usize

### impl Gcd for usize

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

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

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

$$ f(x, y) = \gcd(x, y). $$

##### §Worst-case complexity

$T(n) = O(n^2)$

$M(n) = O(n)$

`max(self.significant_bits(), other.significant_bits())`

.

##### §Examples

See here.