The factorial, extended — with the (n − 1) shift stated every time and the overflow handled honestly.
Gamma, log-gamma and beta
Γ(n) = (n − 1)! — the shift is stated every time.
Any real number except zero and the negative integers, where Γ has poles.
x = 0.5
Γ(x) = 1.77245385091
0 < x < 1, where Γ falls from +∞ at 0 to Γ(1) = 1. Γ(½) = √π = 1.772453851 sits in this stretch.
Γ(x)
1.77245385091
direct
lnΓ(x)
0.572364942925
finite far past where Γ overflows
ψ(x) — digamma
−1.963510026
Γ′(x)/Γ(x), the logarithmic derivative
Γ(x+1) = x·Γ(x)
holds
0.8862269255 vs 0.8862269255
Reflection. Γ(0.5) × Γ(1 − 0.5) = π / sin(π × 0.5) — 3.141592654 against 3.141592654, which agree.
Landmarks
Reference values of the gamma function
x
Γ(x)
What it is
1/2
1.772453851
exactly √π — forced by the definition, not chosen
1
1
= 0!, the empty product
1.4616321
0.8856032
the minimum of Γ for positive x
2
1
= 1!, so Γ takes the same value at 1 and 2
5
24
= 4!, the shift on display
−1/2
−3.544907702
= −2√π, negative because it sits between the poles at −1 and 0
The beta function, B(a, b)
B(2, 3)
0.0833333333333
lnB = −2.48490664979, and B(a,b) = B(b,a)
With whole-number arguments, 1/B(2, 3) = 4 × C(3, 1) = 12 — so the beta function is a binomial coefficient in disguise, which is exactly how it turns up in the beta distribution.
ψ(x) = Γ′(x)/Γ(x) is the logarithmic derivative — the rate at which lnΓ grows. It is the natural "derivative of the factorial", and like Γ itself it has no elementary closed form. ψ(1) = −γ = −0.5772156649, the negative of the Euler–Mascheroni constant, which is where that constant first appears in most courses.
Γ(x) = ∫₀^∞ t^(x−1) e^(−t) dt for x > 0, extended to the rest of the plane by Γ(x + 1) = x·Γ(x). Integrating by parts turns that integral into exactly the recurrence, which is why it interpolates the factorial at all — and the Bohr–Mollerup theorem says log-convexity makes it the ONLY function that does.
Verified against exact big-integer factorials up to 171! — worst relative error 1.6×10⁻¹³.
What this tool shows
The factorial extended to every argument except the poles — with the shift stated and the overflow handled.
Γ(x), lnΓ(x) and ψ(x) for any argument except the poles
Values past x ≈ 171.6 reconstructed from lnΓ rather than reported as Infinity
The poles explained through the reflection formula, which also gives negative values
The beta function computed in logarithms, so B(200, 300) is a number
The (n−1)! shift stated every time Values past the double overflow Digamma and beta too Free, no signup
Free, no signup — verified against exact factorials.
Updated 6 September 2026 · Works in any browser, no installation
Γ(n) = (n − 1)! for a positive integer n — the argument is one MORE than the factorial being taken. Γ(5) = 24, which is 4! rather than 5!. And Γ(½) = 1.77245385091, exactly √π.
At a glance
Formula shown
\u0393(x) = \u222b\u2080^\u221e t^(x\u22121) e^(\u2212t) dt, with \u0393(x+1) = x\u00b7\u0393(x). For positive integers \u0393(n) = (n\u22121)!.
Scenario support
Any real argument except zero and the negative integers, where \u0393 has poles.
Educational estimate
Planning support from the values you enter — not professional advice.
The shift, and why it keeps producing wrong answers
x is a positive integer, so Γ(5) = 4! = 24. Note the shift: the argument is one MORE than the factorial being taken. This is the single most common mistake with the gamma function and it is a definition, not a convention anyone can change.
There is no way to argue this away. Legendre’s definition put the shift there, every table and library since has followed, and changing it now would break every reference in existence. The only defence is to state it, which this page does on every integer input.
The practical consequence: “the factorial of 4.5” means Γ(5.5), not Γ(4.5). Getting that wrong shifts the answer by a whole factor, and the result is usually plausible enough not to be caught.
Why Γ(½) is √π and not a convention
Γ(½) = 1.77245385091 = √π. That looks like a coincidence and is not — it is forced, and the forcing is worth seeing.
Substituting t = u² in the defining integral turns Γ(½) into 2∫₀∞ e⁻ᵘ² du, which is the Gaussian integral. Its value is √π, and so is Γ(½).
More fundamentally, the Bohr–Mollerup theorem says Γ is the ONLY function that interpolates the factorial while staying log-convex. Without that second condition there are infinitely many smooth interpolations; with it there is exactly one, and it has no freedom left to make Γ(½) anything else.
Between 1 and 2, where Γ has its only minimum for positive x: about 0.8856 at x ≈ 1.4616. It rises without bound on both sides of that.
The poles, and what the reflection formula explains
Γ has a simple pole at every non-positive integer, so Γ(-3) is undefined. The reflection formula shows why: Γ(x)Γ(1−x) = π/sin(πx), and sin(πx) is zero at every integer — so one of the two gammas has to be infinite there. For positive integers it is Γ(1−x) that blows up; for x ≤ 0 it is Γ(x) itself.
The reflection formula Γ(x)Γ(1−x) = π/sin(πx) accounts for the whole structure in one line. sin(πx) is zero at every integer, so the left side must be infinite there, so one of the two gammas blows up — and for x ≤ 0 it is Γ(x) itself.
It also produces the negative values. x is negative and not an integer, so Γ(x) is finite but sits between two poles at 0 and -1. Between each consecutive pair of poles Γ takes the opposite sign to the pair before, which is why its graph alternates below and above the axis as x goes more negative. Γ(−½) = −3.54490770181, which is −2√π, and the tool checks the reflection formula on it: Γ(−0.5) × Γ(1 − −0.5) = π / sin(π × −0.5) gives −3.141592654 against −3.141592654, which agree.
Between consecutive negative poles Γ alternates sign, which is why its graph flips above and below the axis as x runs more negative — another fact the reflection formula gives for free, since sin(πx) alternates sign between integers.
Past the overflow, and why Infinity is the wrong answer
Γ passes the largest double at about x = 171.6. Beyond that a naive implementation returns Infinity for numbers that exist perfectly well and have a few hundred digits.
Γ(175) is larger than the biggest double (about 1.8 × 10³⁰⁸), so the direct value overflows — Γ passes that ceiling at x ≈ 171.6. lnΓ(175) = 727.174567173 is an ordinary number, and the value above was reconstructed from it. Anything that would multiply or divide gammas this large should work in lnΓ throughout.
9.32096310408 × 10^156 for Γ(100.5) is comfortably inside the range; 6.425426 × 10^315 for Γ(175) is not, and comes from exponentiating lnΓ. The page marks which route each value took.
The general lesson for code: any expression that multiplies or divides large gammas should be written in lnΓ throughout and exponentiated once at the end, if at all. The beta function below is the standard example.
Digamma, and the derivative of a factorial
ψ(x) = Γ′(x)/Γ(x) is the logarithmic derivative — the rate at which lnΓ grows. It is the natural "derivative of the factorial", and like Γ itself it has no elementary closed form. ψ(1) = −γ = −0.5772156649, the negative of the Euler–Mascheroni constant, which is where that constant first appears in most courses.
ψ(x) = Γ′(x)/Γ(x) is the logarithmic derivative, and it is the natural answer to “what is the derivative of a factorial” — a question that has no elementary answer either, for the same reason Γ itself does not.
At x = 5 it is 1.506117668. It satisfies its own recurrence, ψ(x+1) = ψ(x) + 1/x, which makes ψ at integer arguments a harmonic number minus γ — the point where the Euler–Mascheroni constant enters most courses.
The beta function, and why it is computed in logarithms
B(a, b) = Γ(a)Γ(b)/Γ(a+b), and written that way it is unusable for large arguments: B(200, 300) = 1.64854916087 × 10^−147, while Γ(200), Γ(300) and Γ(500) are all past the overflow — the ratio as written is Infinity ÷ Infinity.
Computed as exp(lnΓ(a) + lnΓ(b) − lnΓ(a+b)) it is an ordinary small number. lnB = −337.980113065, and the value follows.
With whole-number arguments, 1/B(2, 3) = 4 × C(3, 1) = 12 — so the beta function is a binomial coefficient in disguise, which is exactly how it turns up in the beta distribution.
Which is why the beta function turns up wherever binomial coefficients do with non-integer arguments — the beta distribution, Bayesian priors on a probability, and the normalising constant of Student’s t.
Sources and methodology
The gamma function, its reflection formula and the beta function are standard; the references below carry the canonical statements.
Method. Every figure on this page comes from src/lib/gamma-function.ts over src/lib/algebra/special.ts. Γ uses the Lanczos approximation with g = 7 and nine coefficients, plus the reflection formula below x = ½; when the Lanczos product overflows on the way to a representable value, the result is recovered through lnΓ. The beta function is always computed in logarithms. That engine is verified on every change against 76 hand-written assertions, including agreement with exact big-integer factorials up to 171! to better than 1.6e-13 relative, and that the recurrence and reflection formulas hold at every tested argument. The count and the per-case breakdown are published on the formula verification page.
Related calculators
Where this goes next:
Error Functionerf, erfc and the inverse to full double precision through the incomplete gamma function, with the normal-distribution conversion and a demonstration of why 1 minus erf fails.
Hyperbolic FunctionsAll six hyperbolic functions and their inverses, built visibly from e^x and e^-x, with cosh squared minus sinh squared computed rather than asserted and every domain limit stated.
Bessel FunctionJ, Y, I and K plus the spherical pair, with the zeros that set drum modes and waveguide cutoffs, the recurrence and Wronskian checked, and the measured accuracy stated per family.
Binomial Coefficientn choose k exactly on big integers, by the multiplicative formula that never builds a number bigger than the answer — with Pascal's rule, the row it sits in, and permutations beside it.
Standard DeviationSample and population standard deviation, plus variance, mean, median, quartiles, z-scores, outliers, and confidence intervals.
ScientificTrigonometry, logarithms, powers, roots, and factorials with correct order of operations, memory registers, history, and keyboard entry.
The gamma function is the parent of the incomplete gamma family, which is where the Error Function Calculator gets its precision. For exact factorials of whole numbers with no approximation at all, the Binomial Coefficient Calculator works on big integers instead.
Educational use disclaimer
This calculator evaluates the gamma function and its relatives in double precision, using the Lanczos approximation with the reflection formula for negative arguments. Accuracy is around 1e-13 relative or better, verified against exact big-integer factorials. Γ has poles at zero and the negative integers and the page reports those as undefined rather than as very large numbers.
Published the gamma function page: Γ, lnΓ, digamma and beta, with the Γ(n) = (n − 1)! shift stated every time rather than left to be discovered in a wrong answer.
Reconstructs values past the double overflow near x = 171.6 from lnΓ instead of reporting Infinity for a number that exists.
Explains the poles through the reflection formula, which accounts for both their positions and the sign flips between them.
Add this calculator to your site
Responsive embed — and private: nothing your visitors type leaves their browser.