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
| Parameter | Type | Required | Description |
|---|---|---|---|
n | T | Yes | Non-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 BIGINT | f2 BIGINT | f3 BIGINT |
|---|---|---|
| 1 | 120 | 6 |
On this page