# libm.info: gamma

Go forward to hypot
Go backward to frexp
Go up to Math
Go to the top op libm

# `gamma', `gammaf', `lgamma', `lgammaf', `gamma_r',

```*Synopsis*
#include <math.h>
double gamma(double X);
float gammaf(float X);
double lgamma(double X);
float lgammaf(float X);
double gamma_r(double X, int *SIGNGAMP);
float gammaf_r(float X, int *SIGNGAMP);
double lgamma_r(double X, int *SIGNGAMP);
float lgammaf_r(float X, int *SIGNGAMP);
*Description*
`gamma' calculates the natural logarithm of the gamma function of X.
The gamma function (`exp(gamma(X))') is a generalization of factorial,
and retains the property that `exp(gamma(N))' is equivalent to
`N*exp(gamma(N-1))'.  Accordingly, the results of the gamma function
itself grow very quickly.  `gamma' is defined as the natural log of the
gamma function, rather than the gamma function itself, to extend the
useful range of results representable.```
```   The sign of the result is returned in the global variable `signgam',
which is declared in math.h.```
```   `gammaf' performs the same calculation as `gamma', but uses and
returns `float' values.```
```   `lgamma' and `lgammaf' are alternate names for `gamma' and `gammaf'.
The use of `lgamma' instead of `gamma' is a reminder that these
functions compute the log of the gamma function, rather than the gamma
function itself.```
```   The functions `gamma_r', `gammaf_r', `lgamma_r', and `lgammaf_r' are
just like `gamma', `gammaf', `lgamma', and `lgammaf', respectively, but
```*Returns*
```   When X is a nonpositive integer, `gamma' returns `HUGE_VAL' and
`   You can modify this error treatment using `matherr'.`
```*Portability*