FactorialL function

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Math

Package: Microsoft.Quantum.Standard

Returns the factorial of a given integer.

function FactorialL (n : Int) : BigInt

Input

n : Int

The number to take the factorial of.

Output : BigInt

The factorial of the provided input.

Remarks

This function returns exact factorials for arbitrary-size integers, using a recursive decomposition into double-factorials ($n!!$). In particular, if $n = 2k + 1$ for $k \in \mathbb{N}$, then: $$ n! = n!! \times k! \times 2^k, $$ where $k!$ can be computed recursively. If $n$ is even, then we can begin the recursion by computing $n! = n \times (n - 1)!$.

See Also