pub trait CheckedSubfactorial: Sized {
    fn checked_subfactorial(n: u64) -> Option<Self>;
}

Required Methods

Implementations on Foreign Types

Computes the subfactorial of a number.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Computes the subfactorial of a number.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Computes the subfactorial of a number.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Computes the subfactorial of a number.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Computes the subfactorial of a number.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Computes the subfactorial of a usize.

The subfactorial of $n$ counts the number of derangements of a set of size $n$; a derangement is a permutation with no fixed points.

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.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors