factorial
factorial(
n):bigint
Defined in: factorial.ts:26
The factorial n! = 1 × 2 × … × n, with 0! = 1.
Returns a bigint because 21! already exceeds Number.MAX_SAFE_INTEGER.
Amortised O(1) for repeated calls at or below 256, which is where the consumers sit: the table is extended only as far as it has not already reached. Above that the tail is multiplied out each time rather than stored.
Parameters
Section titled “Parameters”number
A non-negative integer.
Returns
Section titled “Returns”bigint
n! as an exact integer.