gamma
The gamma() function returns the gamma function of a given number. The gamma function extends the factorial to real numbers: for a positive integer n, gamma(n) equals (n - 1)!.
Arguments
-
number: A requireddouble precisionvalue.gamma()acceptsrealvalues and computes them asdouble precision.
Return type
gamma() returns a double precision value, or NULL if the argument is NULL. If the result cannot be represented as a double precision value, gamma() returns an error instead. See Out-of-range inputs.
Examples
Out-of-range inputs
The gamma function is undefined or unrepresentable for some inputs. In these cases gamma() returns an error rather than infinity or NaN:
-
Zero and the negative integers are poles of the gamma function.
gamma(0)and, for example,gamma(-2)fail with:value out of range: overflow -
Inputs whose result is too large for
double precisionfail with the samevalue out of range: overflowerror. The largest integer with a representable result is171, sogamma(172)overflows. -
Large negative, non-integer inputs whose result is too small to represent fail with:
value out of range: underflow
For the special floating-point values, gamma() returns NaN for NaN and positive infinity for positive infinity. Negative infinity fails with value out of range: overflow.