FACTORIAL()

All functions > MATH > FACTORIAL()

Returns the factorial of a non-negative integer (n!).

Signatures

Factorial

Returns: n! as an integer

FACTORIAL(n: T) → BIGINT
sql
ParameterTypeRequiredDescription
nTYesNon-negative integer

With:

  • T : Integer type (TINYINT … BIGINT)

Signature notes:

  • Defined for non-negative integers; negative inputs fail at evaluation time
  • Returns NULL if the input is NULL
  • Very large n can exceed BIGINT range and fail at evaluation time

Examples

FeatureQL
SELECT
    f1 := FACTORIAL(0), -- 0! = 1
    f2 := FACTORIAL(5), -- 5!
    f3 := FACTORIAL(3) -- 3!
;
Result
f1 BIGINTf2 BIGINTf3 BIGINT
11206

Last update at: 2026/05/26 17:22:09