StatGardenREF. DESK
Calculators/Maths/Gamma function
Maths

Gamma function calculator

Evaluates the gamma function Γ(x) for any real x, extending the factorial to non-integers.

Published 9 August 2026 · Updated 24 September 2026

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

FormulaΓ(x) = ∫₀^∞ tˣ⁻¹e⁻ᵗ dt, with Γ(n) = (n−1)! for positive integers n. Computed via the Lanczos approximation

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.

TermMeaning
Γ(x)The gamma function evaluated at x, defined by the integral of tˣ⁻¹e⁻ᵗ from 0 to infinity.
Factorial offsetThe relationship Γ(n) = (n − 1)! that holds at every positive integer n.
RecurrenceThe identity Γ(x + 1) = x·Γ(x), which is what makes gamma behave like a factorial between the integers as well as at them.
Lanczos approximationThe standard numerical method for evaluating gamma to high accuracy without performing the integral.

The inputs explained

FieldWhat to enter
xThe 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.

Positive integer arguments
xΓ(x)Equivalent factorial
11.0000000! = 1.000000
21.00001! = 1.0000
32.00002! = 2.0000
46.00003! = 6.0000
524.00004! = 24.0000
6120.00005! = 120.0000
Every row is the factorial of one less than x. Γ(5) is 24, which is 4 factorial, not 5 factorial. The first two rows both give 1, since 0! and 1! are both 1, which is the only place the sequence repeats itself.

What is the gamma function at half-integers?

Gamma at the half-integers, the arguments that turn up most often in statistical distributions.

Arguments ending in a half
xΓ(x)
0.51.7725
1.50.886227
2.51.3293
3.53.3234
4.511.6317
Γ(0.5) is 1.7725, which is the square root of π. Every later row follows from the recurrence Γ(x + 1) = x·Γ(x): 0.5 × 1.7725 gives the 0.886227 on the second row, and 1.5 × 0.886227 gives the 1.3293 on the third. The whole half-integer sequence is built out of √π in this way.

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.