Statistical function

GAMMA function

Returns the gamma function of a number, the smooth extension of the factorial that also works for fractions.

Available in Excel 2013 and later, Microsoft 365, Excel for the web

Excel 2013 and laterWorks in Google Sheets

Syntax

GAMMA(number)
ArgumentWhat it means
numberRequiredThe value to evaluate. Any real number except 0 and negative whole numbers.

Returns: A number: Γ(number). For a positive whole number n, GAMMA(n) equals FACT(n-1).

How GAMMA works

The gamma function is the mathematician's answer to the question "what is the factorial of 4.5?". For whole numbers it lines up with the factorial shifted by one: GAMMA(5) is 4 × 3 × 2 × 1 = 24, the same as FACT(4). Between whole numbers it draws a smooth curve, so GAMMA(4.5) lands neatly between 6 and 24.

In a spreadsheet you rarely need GAMMA on its own. It appears inside the formulas of the gamma, beta, chi-squared and Student's t distributions, and it is handy when you are rebuilding one of those formulas by hand to check a result. If the numbers get large, switch to GAMMALN, which returns the natural logarithm and never overflows; GAMMA itself returns #NUM! once the answer passes about 1.8 × 10^308 (a little above GAMMA(171)).

Examples

1Gamma of a whole number equals a factorial

B2fx=GAMMA(A2)
ABC
1nGAMMA(n)FACT(n-1)
252424

Result: 24

Γ(5) = 4! = 24. For every positive whole number n, GAMMA(n) and FACT(n-1) give the same answer.

2Gamma of one half

B2fx=GAMMA(A2)
AB
1InputResult
20.51.7725

Result: 1.7725

Γ(0.5) is exactly the square root of π, 1.7724538509…; shown here to 4 decimal places. It is a classic check value: =SQRT(PI()) gives the same number.

3Negative fractions are allowed, negative integers are not

B2fx=GAMMA(A2)
AB
1InputResult
2-1.52.3633
3-2

Result: 2.3633

Γ(-1.5) = 2.363272 (shown to 4 decimals). The same formula copied to B3 for -2 returns #NUM!, because the gamma function has a pole at 0 and at every negative whole number.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!number is 0 or a negative whole number, or the result is too large (number above about 171.6).Check the input; for big values use =GAMMALN(x) and work with logarithms.
#VALUE!number is text that cannot be read as a number.Make sure the cell holds a real number, not text such as "5 units".

Tips

  • GAMMA(n+1) = FACT(n) for whole n, but GAMMA also accepts fractional inputs where FACT would truncate them.
  • To divide two huge gamma values, use =EXP(GAMMALN(a)-GAMMALN(b)) instead of =GAMMA(a)/GAMMA(b) to avoid overflow.

Google Sheets

GAMMA also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

GAMMA in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
Portuguese (Brazil)GAMA
Portuguese (Portugal)GAMA
RussianГАММА
TurkishGAMA