gamma

gamma(n)

Try it yourself:

See also:

Extend factorials with gamma

gamma(n) evaluates the gamma function, which satisfies gamma(n) = (n - 1)! for positive integers. It extends factorial-style calculations to non-integer and complex values.

Examples

gamma(6) is 120, and gamma values also exist for positive fractional inputs. This makes gamma useful in continuous probability distributions and special-function formulas. Use factorial for ordinary non-negative integer counts and lgamma for a logarithmic representation.

Domain caveats

Gamma has poles at zero and negative integers, so those inputs are undefined. Values can grow rapidly, and floating-point evaluation may lose precision near poles. round is useful for display but should not hide a near-singular input. For binomial-style quantities, combinations is normally the clearer function.

All functions