Categories: Math
FACTORIAL
Computes the factorial of an integer. Input must be between 0 and 20 (21! overflows BIGINT). Returns NULL if the input is NULL.
Syntax
FACTORIAL(expression integer) → bigint
- expression: Integer in the range
0to20.
Examples
FACTORIAL exampleSELECT FACTORIAL(0), FACTORIAL(1), FACTORIAL(5), FACTORIAL(20)
-- 1, 1, 120, 2432902008176640000
SELECT FACTORIAL(NULL)
-- null