Gamma Function Calculator
Calculate the gamma function for real inputs, extending factorial beyond integers. Useful in calculus, statistics, and probability distributions.
Enter the Details
Result will appear here...
What this calculator does
You know how to take the factorial of a whole number: 5 factorial is 5 times 4 times 3 times 2 times 1. But what would half a factorial be, or the factorial of 3.7? The gamma function is the answer. It extends the factorial to fractions, decimals and beyond, drawing a smooth curve through all the factorial points. This computes it.
Enter a number and it returns its gamma value. It runs right here in the browser.
Using the calculator
- Enter a number.
- Press Calculate.
It returns the gamma function of that number. Reset clears the box.
What the gamma function is
The factorial only makes sense for whole numbers, because you cannot multiply together "3.7 down to 1". Yet mathematicians kept needing a version that worked for any number, one that still matched the ordinary factorial at the whole numbers but filled in every gap in between with a smooth, continuous curve. The gamma function, written with the capital Greek letter for G, is that function.
There is one quirk of history to get used to. The gamma function is shifted by one from the factorial, so that gamma of n equals (n minus 1) factorial. That means gamma of 5 is 4 factorial, which is 24, not 5 factorial. The offset looks odd, but it is baked into the standard definition and you simply carry it along.
Euler's integral, the definition
So where does this smooth curve actually come from? Leonhard Euler found it, around 1729, in the form of an integral, an area under a curve:
gamma of x = the area under t(x − 1) times e−t, from t = 0 out to infinity
You do not need to evaluate that by hand, and this tool does not ask you to. The remarkable thing is simply that this particular area, worked out for each value of x, reproduces the factorial exactly at the whole numbers and smoothly connects them everywhere else. It was a beautiful piece of insight: turning a counting operation into a continuous one by way of an integral.
The rule it inherits from the factorial
The gamma function keeps the essential behaviour of the factorial. The factorial obeys n factorial equals n times (n minus 1) factorial, each value built from the one below. The gamma function has the exact same shape of rule:
gamma of (x + 1) = x times gamma of x
This is the continuous echo of the factorial's step-by-step rule, and it is really why the gamma function earns the right to be called the factorial's extension. It does not just happen to agree at the whole numbers; it grows by the same rule everywhere.
Special values, and a surprise
A few values are worth knowing. Gamma of 1 is 1, and gamma of any whole number n is (n minus 1) factorial, as above. But the loveliest result appears at a half. It turns out that:
gamma of one half = √π ≈ 1.7725
That is a genuine surprise. Ask for the "factorial" of a half and out pops the square root of pi, a number from circles. This is no accident: it comes straight from the famous Gaussian integral that sits under the bell curve, which is the same reason the gamma function is so tied up with probability. A counting function, reaching into the world of pi and the normal distribution.
Worked examples
Gamma of 5. By the rule, this is (5 minus 1) factorial, which is 4 factorial, which is 4 times 3 times 2 times 1 = 24. So at the whole numbers the gamma function is just the familiar factorial, shifted by one.
Gamma of one half. This is √π, which is about 1.77245. Here you are well off the whole numbers, in territory the plain factorial cannot reach, and the gamma function answers without hesitation.
Where it is used
The gamma function is everywhere once you leave the whole numbers behind. It is the backbone of several probability distributions that carry its name or its fingerprint, including the gamma, beta and chi-squared distributions used throughout statistics. It appears in physics, in the study of series and integrals, and anywhere a factorial is needed at a value that is not a whole number. To compute it quickly and accurately, this tool uses the math.js library, which evaluates the gamma function with the Lanczos approximation, a formula that delivers many correct digits with very little work.
Questions people ask
What is the gamma function?
A smooth function that extends the factorial to fractions, decimals and complex numbers, agreeing with the ordinary factorial at the whole numbers.
How is it related to the factorial?
Gamma of n equals (n minus 1) factorial for whole numbers. So gamma of 5 is 4 factorial, which is 24. There is a shift of one between them.
Why is gamma of one half the square root of pi?
Because its defining integral is the Gaussian integral that underlies the bell curve, whose value involves the square root of pi. This links the gamma function to probability.
What is the recurrence relation?
Gamma of (x plus 1) equals x times gamma of x, the continuous version of the factorial's own step-by-step rule.
Where is the gamma function used?
In statistics (the gamma, beta and chi-squared distributions), in physics, and anywhere a factorial is needed at a non-whole number.
References
A note on where this comes from. The gamma function extends the factorial to real and complex numbers, defined by Euler's integral, gamma of x equal to the integral from 0 to infinity of t to the (x minus 1) times e to the minus t. Leonhard Euler introduced it around 1729 in correspondence with Christian Goldbach, and Adrien-Marie Legendre later gave it the notation and name in use today. For further reading, see the NIST Digital Library of Mathematical Functions, Chapter 5, at https://dlmf.nist.gov/5.
- Leonhard Euler, who introduced the integral extension of the factorial around 1729, in letters to Christian Goldbach.
- Adrien-Marie Legendre, who gave the gamma function its modern notation and name.
- NIST Digital Library of Mathematical Functions, Chapter 5 (Gamma Function), the standard modern reference.
- math.js, the JavaScript library used here, which computes the gamma function via the Lanczos approximation.
Okan Atalay is a results driven senior operations manager and a graduate of Industrial Engineering from Bilkent University. With over 22 years of experience in textile manufacturing and integrated operations, he has led large scale business process improvements and strategic planning initiatives. Currently, he serves as a top mathematics expert for a global ed tech platform, where he applies his analytical expertise to solve complex mathematical problems. At Eon Tools, he reviews converter and maths tools.
Other Tools
- Absolute Value Equation Calculator
- Binomial Coefficient Calculator
- Combination Calculator
- Complementary Error Function Calculator
- Completing The Square Calculator
- Complex Number Calculator
- Discriminant Calculator
- Elimination Method Calculator
- Error Function Calculator
- Foil Calculator
- Interval Notation Calculator
- Permutation Calculator
- Polynomial Division Calculator
- Quadratic Formula Calculator
- System Of Equations Calculator