Trait malachite_base::num::arithmetic::traits::CheckedDoubleFactorial
source · pub trait CheckedDoubleFactorial: Sized {
// Required method
fn checked_double_factorial(n: u64) -> Option<Self>;
}
Expand description
Computes the double factorial of a u64
, returning None
if the result is too large to be
represented. The double factorial of a non-negative integer is the product of all the positive
integers that are less than or equal to it and have the same parity as it.
Required Methods§
fn checked_double_factorial(n: u64) -> Option<Self>
Object Safety§
Implementations on Foreign Types§
source§impl CheckedDoubleFactorial for u8
impl CheckedDoubleFactorial for u8
source§fn checked_double_factorial(n: u64) -> Option<u8>
fn checked_double_factorial(n: u64) -> Option<u8>
Computes the double factorial of a number.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedDoubleFactorial for u16
impl CheckedDoubleFactorial for u16
source§fn checked_double_factorial(n: u64) -> Option<u16>
fn checked_double_factorial(n: u64) -> Option<u16>
Computes the double factorial of a number.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedDoubleFactorial for u32
impl CheckedDoubleFactorial for u32
source§fn checked_double_factorial(n: u64) -> Option<u32>
fn checked_double_factorial(n: u64) -> Option<u32>
Computes the double factorial of a number.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedDoubleFactorial for u64
impl CheckedDoubleFactorial for u64
source§fn checked_double_factorial(n: u64) -> Option<u64>
fn checked_double_factorial(n: u64) -> Option<u64>
Computes the double factorial of a number.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedDoubleFactorial for u128
impl CheckedDoubleFactorial for u128
source§fn checked_double_factorial(n: u64) -> Option<u128>
fn checked_double_factorial(n: u64) -> Option<u128>
Computes the double factorial of a number.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedDoubleFactorial for usize
impl CheckedDoubleFactorial for usize
source§fn checked_double_factorial(n: u64) -> Option<usize>
fn checked_double_factorial(n: u64) -> Option<usize>
Computes the double factorial of a usize
.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n!!) & \text{if} \quad n!! < 2^W, \\
\operatorname{None} & \text{if} \quad n!! \geq 2^W,
\end{cases}
$$
where $W$ is usize::WIDTH
.
$n!! = O(\sqrt{n}(n/e)^{n/2})$.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.