Trait malachite_base::num::arithmetic::traits::CoprimeWith
source · [−]pub trait CoprimeWith<RHS = Self> {
fn coprime_with(self, other: RHS) -> bool;
}
Expand description
Determines whether two numbers are coprime.
Required Methods
fn coprime_with(self, other: RHS) -> bool
Implementations on Foreign Types
sourceimpl CoprimeWith<u8> for u8
impl CoprimeWith<u8> for u8
sourcefn coprime_with(self, other: u8) -> bool
fn coprime_with(self, other: u8) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.
sourceimpl CoprimeWith<u16> for u16
impl CoprimeWith<u16> for u16
sourcefn coprime_with(self, other: u16) -> bool
fn coprime_with(self, other: u16) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.
sourceimpl CoprimeWith<u32> for u32
impl CoprimeWith<u32> for u32
sourcefn coprime_with(self, other: u32) -> bool
fn coprime_with(self, other: u32) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.
sourceimpl CoprimeWith<u64> for u64
impl CoprimeWith<u64> for u64
sourcefn coprime_with(self, other: u64) -> bool
fn coprime_with(self, other: u64) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.
sourceimpl CoprimeWith<u128> for u128
impl CoprimeWith<u128> for u128
sourcefn coprime_with(self, other: u128) -> bool
fn coprime_with(self, other: u128) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.
sourceimpl CoprimeWith<usize> for usize
impl CoprimeWith<usize> for usize
sourcefn coprime_with(self, other: usize) -> bool
fn coprime_with(self, other: usize) -> bool
Returns whether two numbers are coprime; that is, whether they have no common factor other than 1.
Every number is coprime with 1. No number is coprime with 0, except 1.
$f(x, y) = (\gcd(x, y) = 1)$.
$f(x, y) = ((k,m,n \in \N \land x=km \land y=kn) \implies k=1)$.
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.