Skip to main content
Scalar function
NULL input or an input outside 0 through 20 returns NULL. factorial(0) is 1.

Syntax

Integer (scalar)

Arguments

Returns

  • Type: BIGINT
  • Possible values: 1 through 2432902008176640000 for supported integer inputs.
  • NULL behavior: NULL input or an input outside 0 through 20 returns NULL. factorial(0) is 1.

Properties

Usage notes

  • Numeric input is converted to BIGINT. Use an explicit BIGINT cast when the conversion affects your result.

Examples

Basic call

Zero and upper boundary

NULL and out-of-range inputs

Limitations

  • Only the factorials of integers from 0 through 20 fit the supported range. Negative inputs and values above 20 produce NULL.
Last modified on October 15, 2026