Skip to main content

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 0 to 20.

Examples

FACTORIAL example
SELECT FACTORIAL(0), FACTORIAL(1), FACTORIAL(5), FACTORIAL(20)
-- 1, 1, 120, 2432902008176640000
Return NULL for a NULL input
SELECT FACTORIAL(NULL)
-- null