Function gamma #

Compute the gamma function of a value using Lanczos approximation for small values, and an extended Stirling approximation for large values.

To avoid confusion with the matrix Gamma function, this function does not apply to matrices.

Syntax #

math.gamma(n)

Parameters #

Parameter Type Description
n number | BigNumber | Complex A real or complex number

Returns #

Type Description
number | BigNumber | Complex The gamma of n

Throws #

Type | Description —- | ———–

Examples #

math.gamma(5)       // returns 24
math.gamma(-0.5)    // returns -3.5449077018110335
math.gamma(math.i)  // returns -0.15494982830180973 - 0.49801566811835596i

See also #

combinations, factorial, permutations

Fork me on GitHub