pub trait Subfactorial {
    fn subfactorial(n: u64) -> 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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

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 panics. For a function that returns None instead, try checked_subfactorial.

$$ f(n) = \ !n = \lfloor n!/e \rfloor. $$

$!n = O(n!) = O(\sqrt{n}(n/e)^n)$.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if the output is too large to be represented.

Examples

See here.

Implementors§