pub trait ModProduct<A = Self, M = Self>: Sized {
// Required method
fn mod_product<I: Iterator<Item = A>>(xs: I, m: M) -> Self;
}Expand description
Multiplies together the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
Like Product, this is implemented both for iterators of values and for
iterators of references. The product of no numbers is 1 reduced modulo $m$, which is 0 when $m =
1$.
Required Methods§
fn mod_product<I: Iterator<Item = A>>(xs: I, m: M) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ModProduct for u8
impl ModProduct for u8
Source§fn mod_product<I: Iterator<Item = u8>>(xs: I, m: u8) -> u8
fn mod_product<I: Iterator<Item = u8>>(xs: I, m: u8) -> u8
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl ModProduct for u16
impl ModProduct for u16
Source§fn mod_product<I: Iterator<Item = u16>>(xs: I, m: u16) -> u16
fn mod_product<I: Iterator<Item = u16>>(xs: I, m: u16) -> u16
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl ModProduct for u32
impl ModProduct for u32
Source§fn mod_product<I: Iterator<Item = u32>>(xs: I, m: u32) -> u32
fn mod_product<I: Iterator<Item = u32>>(xs: I, m: u32) -> u32
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl ModProduct for u64
impl ModProduct for u64
Source§fn mod_product<I: Iterator<Item = u64>>(xs: I, m: u64) -> u64
fn mod_product<I: Iterator<Item = u64>>(xs: I, m: u64) -> u64
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl ModProduct for u128
impl ModProduct for u128
Source§fn mod_product<I: Iterator<Item = u128>>(xs: I, m: u128) -> u128
fn mod_product<I: Iterator<Item = u128>>(xs: I, m: u128) -> u128
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl ModProduct for usize
impl ModProduct for usize
Source§fn mod_product<I: Iterator<Item = usize>>(xs: I, m: usize) -> usize
fn mod_product<I: Iterator<Item = usize>>(xs: I, m: usize) -> usize
Multiplies together all the numbers in an iterator, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a u8> for u8
impl<'a> ModProduct<&'a u8> for u8
Source§fn mod_product<I: Iterator<Item = &'a u8>>(xs: I, m: u8) -> u8
fn mod_product<I: Iterator<Item = &'a u8>>(xs: I, m: u8) -> u8
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a u16> for u16
impl<'a> ModProduct<&'a u16> for u16
Source§fn mod_product<I: Iterator<Item = &'a u16>>(xs: I, m: u16) -> u16
fn mod_product<I: Iterator<Item = &'a u16>>(xs: I, m: u16) -> u16
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a u32> for u32
impl<'a> ModProduct<&'a u32> for u32
Source§fn mod_product<I: Iterator<Item = &'a u32>>(xs: I, m: u32) -> u32
fn mod_product<I: Iterator<Item = &'a u32>>(xs: I, m: u32) -> u32
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a u64> for u64
impl<'a> ModProduct<&'a u64> for u64
Source§fn mod_product<I: Iterator<Item = &'a u64>>(xs: I, m: u64) -> u64
fn mod_product<I: Iterator<Item = &'a u64>>(xs: I, m: u64) -> u64
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a u128> for u128
impl<'a> ModProduct<&'a u128> for u128
Source§fn mod_product<I: Iterator<Item = &'a u128>>(xs: I, m: u128) -> u128
fn mod_product<I: Iterator<Item = &'a u128>>(xs: I, m: u128) -> u128
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.
Source§impl<'a> ModProduct<&'a usize> for usize
impl<'a> ModProduct<&'a usize> for usize
Source§fn mod_product<I: Iterator<Item = &'a usize>>(xs: I, m: usize) -> usize
fn mod_product<I: Iterator<Item = &'a usize>>(xs: I, m: usize) -> usize
Multiplies together all the numbers in an iterator of references, modulo another number $m$. Every number must be already reduced modulo $m$.
The product of no numbers is 1 reduced modulo $m$, which is 0 when $m = 1$.
$f((x_i)_ {i=0}^{n-1}, m) = y$, where $y < m$ and $\prod_ {i=0}^{n-1} x_i \equiv y \mod m$.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.count().
§Panics
Panics if m is zero or if any number is greater than or equal to m. As soon as
the partial product is zero, the remaining numbers are not examined, so an unreduced
number after that point is not detected.
§Examples
See here.