Trait malachite_base::num::arithmetic::traits::Multifactorial
source · pub trait Multifactorial {
// Required method
fn multifactorial(n: u64, m: u64) -> Self;
}
Expand description
Computes the $m$-multifactorial of a u64
. The $m$-multifactorial of a non-negative integer $n$
is the product of all integers $k$ such that $0<k\leq n$ and $k\equiv n \pmod m$.
Required Methods§
fn multifactorial(n: u64, m: u64) -> Self
Object Safety§
Implementations on Foreign Types§
source§impl Multifactorial for u8
impl Multifactorial for u8
source§fn multifactorial(n: u64, m: u64) -> u8
fn multifactorial(n: u64, m: u64) -> u8
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.
source§impl Multifactorial for u16
impl Multifactorial for u16
source§fn multifactorial(n: u64, m: u64) -> u16
fn multifactorial(n: u64, m: u64) -> u16
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.
source§impl Multifactorial for u32
impl Multifactorial for u32
source§fn multifactorial(n: u64, m: u64) -> u32
fn multifactorial(n: u64, m: u64) -> u32
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.
source§impl Multifactorial for u64
impl Multifactorial for u64
source§fn multifactorial(n: u64, m: u64) -> u64
fn multifactorial(n: u64, m: u64) -> u64
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.
source§impl Multifactorial for u128
impl Multifactorial for u128
source§fn multifactorial(n: u64, m: u64) -> u128
fn multifactorial(n: u64, m: u64) -> u128
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.
source§impl Multifactorial for usize
impl Multifactorial for usize
source§fn multifactorial(n: u64, m: u64) -> usize
fn multifactorial(n: u64, m: u64) -> usize
Computes a multifactorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try
checked_multifactorial
.
$$ f(n, m) = n!^{(m)} = n \times (n - m) \times (n - 2m) \times \cdots \times i. $$ If $n$ is divisible by $m$, then $i$ is $m$; otherwise, $i$ is the remainder when $n$ is divided by $m$.
$n!^{(m)} = O(\sqrt{n}(n/e)^{n/m})$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if the output is too large to be represented.
§Examples
See here.