GAMMA in Excel: Factorials, Fractional Inputs and Poles
Use Excel GAMMA for positive and negative noninteger arguments, check the factorial offset and recurrence, and avoid zero and negative-integer poles.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: GAMMA(number) evaluates the gamma function. For a positive integer n, its value is (n−1)!, so GAMMA(6) is 120. Fractional inputs are meaningful; zero and negative integers are excluded.
Syntax and domain
=GAMMA(number)
The one required argument is the point at which to evaluate the function. GAMMA is a special mathematical function, not a gamma-distribution probability calculator. Use a distribution function when the task asks for a probability under a model with shape and scale parameters.
Positive inputs are in the mathematical domain. Negative nonintegers also have defined real values, but the sign changes between intervals separated by negative integers. A blanket “all negative values are invalid” rule would therefore reject valid calculations. Microsoft explicitly documents zero and negative integers as #NUM! cases.
Example 1: keep the factorial offset visible
Enter 1, 2, 3, 4 and 6 in A2:A6. In B2 enter and fill down:
=GAMMA(A2)
Expected values are 1, 1, 2, 6 and 120. For these positive integer inputs, a separate control is:
=FACT(A2-1)
The two columns agree mathematically. Using FACT(A2) instead would calculate a different quantity. At A2=6, the incorrect control is 720, six times the desired value.
Example 2: half-integers and a negative noninteger
=GAMMA(0.5)
=GAMMA(1.5)
=GAMMA(2.5)
=GAMMA(-0.5)
Expected results, rounded to nine decimals, are 1.772453851, 0.886226925, 1.329340388 and -3.544907702. They follow from gamma(0.5)=sqrt(pi) and the recurrence gamma(x+1)=x×gamma(x).
In particular, gamma(-0.5) is negative. Applying ABS to every result would silently change valid mathematical output. Fractional arguments should not be rounded to integers merely to make them look like factorial calculations.
Advanced check: use recurrence as a control
For a well-behaved nonzero input in A2, compare:
=GAMMA(A2+1)
=A2*GAMMA(A2)
At A2=3.5, both expectations are approximately 11.631728397. A tolerance-based comparison is more suitable than exact binary equality when reviewing numerical output:
=ABS(GAMMA(A2+1)-A2*GAMMA(A2))<1E-10
This check has a deliberately narrow scale. It is not a universal tolerance for huge gamma values. A successful recurrence check also does not demonstrate that all arguments or precision boundaries have been tested.
Advanced application: a ratio without a large intermediate
Suppose a positive shape parameter x is in A2 and the model needs gamma(x+1)/gamma(x). The recurrence reduces the ratio to x. At x=20, the intended ratio is exactly 20, even though the individual gamma values are much larger.
=GAMMA(21)/GAMMA(20)
For larger positive inputs, a log-domain expression may be useful:
=EXP(GAMMALN(21)-GAMMALN(20))
Both forms have expected result 20 in this modest example. The logarithmic formulation can avoid forming a large intermediate directly, but does not remove floating-point error or make an unrepresentable final value representable. A known recurrence is simpler when it applies.
Errors, poles and troubleshooting
GAMMA(0)andGAMMA(-2)have documented #NUM! expectations. They are poles, not values whose answers should be replaced by zero.- Microsoft documents #VALUE! for invalid nonnumeric input. Check the source cell before wrapping the expression in IFERROR.
- An input very close to a negative integer is different from that integer, and the mathematical value can be large and sensitive to rounding. Displayed digits may conceal that difference.
- A result that differs by a factor of n often indicates confusion between gamma(n) and n!.
- An apparently reasonable small probability is not the purpose of this function. GAMMA returns a special-function value and can be negative or far above 1.
The examples use ordinary finite arguments. Overflow thresholds, underflow, text coercion, blanks and exact numerical behavior near poles have not been verified in Excel. Retain the original input precision and investigate the domain instead of suppressing every error.
Availability and version history
- Current documentation: the dedicated Microsoft reference lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Introduced: Microsoft’s alphabetical function catalog marks GAMMA as introduced in Excel 2013. The exact first build and platform-specific introduction dates are not established here.
- Last functioning version: unknown; a current help listing is not a last-working-build test.
- Evidence checked: October 15, 2026. Official documentation was freshly retrieved; examples below were independently calculated. No native Excel, Mac or web-client execution was performed.
References and verification
- Microsoft GAMMA reference.
- Microsoft function catalog and introduction-marker explanation.
- Editorial testing standards.
Examples use English function names and comma separators. Expected numbers are rounded independent mathematical calculations; documented error expectations are labeled as such. They are not captured Excel output. All illustrative data and policies are fictional.