7.5. factorial — Factorial-related mathematical formula

Factorial-related mathematical functions.

Unsigned math::factorial(Unsigned n)

Return the factorial of n: \(n!\). This function also have an equivalent in math::meta that is intended to run at compile time.

Unsigned math::double_factorial(Unsigned n)

Return the double factorial of n: \(n!! = \prod_{i=1}^{(n+1)/2} (2i-1)\).

Unsigned math::stirling(Unsigned n)

Uses the Stirling formula to approach \(n!\): \(\sqrt{2\pi n}\,\left({n \over {\rm e}}\right)^n\).