What this calculator does
The gamma function extends the factorial to values that are not whole numbers. At the positive integers it lines up exactly with what the factorial already does, offset by one: Γ(5) is 24, which is 4 factorial. Between those integers it does not jump, it curves smoothly, which is the whole reason it exists.
The offset by one catches people out constantly. Γ(n) is (n − 1)!, not n!, so asking for the gamma of 5 gives 24 rather than 120. The convention is a historical accident rather than anything deep, but it is universal, and reading a gamma value as though it were a factorial of the same argument is the most common mistake made with this function.
The formula
The gamma function is defined by an integral that has no closed form for general x, so it is evaluated numerically. This calculator uses the Lanczos approximation, which is accurate to well beyond the digits shown across the whole range it accepts. At positive integers the equivalent factorial is reported alongside, as a check that the offset by one is being applied the way you expect.
| Term | Meaning |
|---|---|
| Γ(x) | The gamma function evaluated at x, defined by the integral of tˣ⁻¹e⁻ᵗ from 0 to infinity. |
| Factorial offset | The relationship Γ(n) = (n − 1)! that holds at every positive integer n. |
| Recurrence | The identity Γ(x + 1) = x·Γ(x), which is what makes gamma behave like a factorial between the integers as well as at them. |
| Lanczos approximation | The standard numerical method for evaluating gamma to high accuracy without performing the integral. |
The inputs explained
| Field | What to enter |
|---|---|
| x | The value to evaluate the gamma function at. Any real number works except zero and the negative integers, where the function has poles and no value exists. |
When to use it
Working with a continuous distribution
The gamma, beta, chi-squared and Student t distributions all have gamma functions in their density formulas, usually at half-integer arguments. Evaluating those directly is often the only awkward step in writing the density out.
Extending a factorial to a fractional argument
Combinatorial expressions occasionally need a factorial of something that is not a whole number, and gamma is the accepted way to supply one. It is the only extension that is both smooth and logarithmically convex, which is what makes it the canonical choice rather than one option among many.
Checking a hand calculation
Gamma identities are easy to misapply, particularly the recurrence and the reflection formula. Evaluating both sides numerically settles whether a rearrangement was done correctly.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How does the gamma function line up with the factorial?
Gamma evaluated at the first six positive integers, with the factorial each one corresponds to.
| x | Γ(x) | Equivalent factorial |
|---|---|---|
| 1 | 1.000000 | 0! = 1.000000 |
| 2 | 1.0000 | 1! = 1.0000 |
| 3 | 2.0000 | 2! = 2.0000 |
| 4 | 6.0000 | 3! = 6.0000 |
| 5 | 24.0000 | 4! = 24.0000 |
| 6 | 120.0000 | 5! = 120.0000 |
What is the gamma function at half-integers?
Gamma at the half-integers, the arguments that turn up most often in statistical distributions.
Questions
Why is Γ(n) equal to (n − 1)! rather than n!?
It comes from the way Euler originally wrote the defining integral, with an exponent of x − 1 rather than x. Nothing important depends on the choice, and a shifted version without the offset exists and is occasionally used, but the convention with the offset is the one that every table, library and textbook follows.
What is the gamma function of a negative number?
It is defined for negative values that are not whole numbers, and it alternates in sign between consecutive negative integers. At zero and at each negative integer it has a pole, so no value exists there and this calculator reports that rather than returning a number.
What is Γ(1/2)?
The square root of π, about 1.772454. It is the value the whole half-integer sequence is built from, and it is why factors of √π appear throughout the normal and chi-squared distributions.
Why extend the factorial at all?
Because a great many formulas in analysis, probability and physics produce expressions that look like factorials but with arguments that are not whole numbers. Having a smooth function that agrees with the factorial where both are defined lets those formulas be written once rather than as separate cases.
For factorials and combinations at whole-number arguments, see the combinations and permutations calculator. For the constant e that appears throughout the defining integral, see the e calculator.