pub trait DoubleFactorial {
    fn double_factorial(n: u64) -> Self;
}

Required Methods

Implementations on Foreign Types

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.

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.

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.

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.

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.

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.

Implementors