Trait malachite_base::num::arithmetic::traits::DoubleFactorial
source · [−]pub trait DoubleFactorial {
fn double_factorial(n: u64) -> Self;
}
Required Methods
fn double_factorial(n: u64) -> Self
Implementations on Foreign Types
sourceimpl DoubleFactorial for u8
impl DoubleFactorial for u8
sourcefn double_factorial(n: u64) -> u8
fn double_factorial(n: u64) -> u8
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl DoubleFactorial for u16
impl DoubleFactorial for u16
sourcefn double_factorial(n: u64) -> u16
fn double_factorial(n: u64) -> u16
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl DoubleFactorial for u32
impl DoubleFactorial for u32
sourcefn double_factorial(n: u64) -> u32
fn double_factorial(n: u64) -> u32
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl DoubleFactorial for u64
impl DoubleFactorial for u64
sourcefn double_factorial(n: u64) -> u64
fn double_factorial(n: u64) -> u64
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl DoubleFactorial for u128
impl DoubleFactorial for u128
sourcefn double_factorial(n: u64) -> u128
fn double_factorial(n: u64) -> u128
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl DoubleFactorial for usize
impl DoubleFactorial for usize
sourcefn double_factorial(n: u64) -> usize
fn double_factorial(n: u64) -> usize
Computes the double factorial of a number.
If the input is too large, the function panics. For a function that returns None
instead, try CheckedDoubleFactorial
.
$$ f(n) = n!! = n \times (n - 2) \times (n - 4) \times \cdots \times i, $$ where $i$ is 1 if $n$ is odd and $2$ if $n$ is even.
Worst-case complexity
Constant time and additional memory.
Examples
See here.