GAMMA
Quirk foundCategory: Statistical · Last tested 2026-09-01
Real compatibility results for the GAMMA function: executed in Excel for the web, Google Sheets and LibreOffice Calc, with desktop Excel behavior from Microsoft’s official documentation (we do not run desktop Excel — Excel for the web is a different application and is executed separately). Syntax and links to that documentation are below.
Support matrix
| Engine | Documented | Live-tested | Verdict |
|---|---|---|---|
| Excel (desktop) | Yes | No — documented only | n/a |
| Excel for the web | — | Yes (recalc, 2026-09-01) | Supported, behaves as documented |
| Google Sheets | Yes | Yes (Drive import, 2026-08-31) | Quirk found |
| LibreOffice Calc | Yes | Yes (25.8.7.3, 2026-08-31) | Quirk found |
LibreOffice version history
We executed the same test cases under each LibreOffice release to show exactly when GAMMA’s support changed — not documentation claims, real results.
| LibreOffice version | Verdict | Tested |
|---|---|---|
| 24.2.0.3 | Quirk found | 2026-08-31 |
| 24.8.7.2 | Quirk found | 2026-08-31 |
| 25.2.0.3 | Quirk found | 2026-08-31 |
| 25.8.7.3 | Quirk found | 2026-08-31 |
Why isn't GAMMA working in LibreOffice?
GAMMA exists in LibreOffice 25.8.7.3, but it is not a drop-in match for
Excel — our executed tests found real behavioral differences (detailed in the test results on this
page). If a formula that works in Excel or Google Sheets misbehaves in LibreOffice, compare your usage
against the failing cases above before assuming your data is wrong.
Why isn’t GAMMA working in Google Sheets?
GAMMA runs in Google Sheets, but our executed cases show it does not match
Excel’s documented behavior on every input (the failing cases are listed on this page). If a
formula that behaves one way in Excel gives you a different answer in Sheets, compare your usage
against those cases before assuming your data is wrong.
Discovered quirks
-
=ROUND(GAMMA(-3.75),12) on
Google Sheets returned
#NUM!, but the documented/expected
result is 0.267866128861.
Provenance
Microsoft publishes '=GAMMA(-3.75)' with the result 0.268. Derived independently with mpmath at 50 digits: Gamma(-3.75) = 0.26786612886141660256, which rounds to the published 0.268. This case matters because the gamma function is only defined for negative arguments by analytic continuation -- an implementation that simply integrates the defining integral cannot reach it -- and because the sign is a real test: Gamma is positive on (-4,-3), and an engine using the reflection formula with a sign slip lands on -0.268.; MISMATCH vs expected: expected 0.267866128861, got '#NUM!'
-
=GAMMA(0) on
LibreOffice Calc returned
#VALUE!, but the documented/expected
result is #NUM!.
Provenance
Excel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and the page's own example table lists '=GAMMA(0)' with the result #NUM!. The gamma function has a pole at 0. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one.; MISMATCH vs expected: expected '#NUM!', got '#VALUE!'
-
=GAMMA(-2) on
LibreOffice Calc returned
#VALUE!, but the documented/expected
result is #NUM!.
Provenance
Excel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and publishes '=GAMMA(-2)' with the result #NUM!. Gamma has poles at every non-positive integer. Asserted alongside GAMMA(-3.75), which is NOT an integer and must return a finite value -- together they check that an engine rejects the poles without rejecting the whole negative axis. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one.; MISMATCH vs expected: expected '#NUM!', got '#VALUE!'
Executed test cases
Excel for the web (executed 2026-09-01 via OneDrive recalculation)
These values come from Excel for the web, not from desktop Excel. They are two different implementations of the calculation engine, and this run measured only the web one: the corpus was uploaded to OneDrive as .xlsx, recalculated by Excel for the web on open, and downloaded again for readback. Excel for the web is a rolling service with no pinnable version, so the run is identified by its date. Where a value here disagrees with the Expected column — which is Microsoft’s documentation of the desktop product — we cannot tell you whether the web engine diverges from the desktop one or the documentation is wrong about both, because we do not run desktop Excel.
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMA(2.5),12) | Microsoft's first worked example | 1.329340388179 | 1.329340388179ProvenanceMicrosoft publishes '=GAMMA(2.5)' with the result 1.329 ("Returns the gamma function value of 2.5 (1.329)"). Derived independently with mpmath at 50 decimal digits: Gamma(2.5) = 1.3293403881791370205, which rounds to the published 1.329 at the three decimals the page prints. Asserted at 12 dp rather than 3 because the page's precision is a display choice, not a limit on the answer, and 12 dp is well inside the ~15 significant digits an IEEE double carries. Cross-checked against the closed form the page itself supplies, Gamma(N+1) = N*Gamma(N): Gamma(2.5) = 1.5*Gamma(1.5) = 1.5*0.5*Gamma(0.5) = 0.75*sqrt(pi) = 1.32934038817913702, identical to 17 digits. |
Matched |
| =ROUND(GAMMA(-3.75),12) | Microsoft's second worked example: a negative non-integer argument | 0.267866128861 | 0.267866128861ProvenanceMicrosoft publishes '=GAMMA(-3.75)' with the result 0.268. Derived independently with mpmath at 50 digits: Gamma(-3.75) = 0.26786612886141660256, which rounds to the published 0.268. This case matters because the gamma function is only defined for negative arguments by analytic continuation -- an implementation that simply integrates the defining integral cannot reach it -- and because the sign is a real test: Gamma is positive on (-4,-3), and an engine using the reflection formula with a sign slip lands on -0.268. |
Matched |
| =GAMMA(5) | At a positive integer n, GAMMA(n) is (n-1)! | 24 | 24ProvenanceDerived from the recurrence the page states, Gamma(N+1) = N*Gamma(N), together with Gamma(1) = 1: Gamma(5) = 4*3*2*1 = 24 = 4!. An exact integer, so this case is asserted with no ROUND wrapper at all and catches any accumulation of floating-point error in a series or Lanczos approximation. |
Matched |
| =ROUND(GAMMA(0.5)-SQRT(PI()),12) | The classical value Gamma(1/2) = sqrt(pi), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed-form value, and the reason it is asserted as a DIFFERENCE against the engine's own SQRT(PI()) is that it then tests the gamma implementation rather than the printing of a constant. mpmath at 50 digits: Gamma(0.5) = 1.7724538509055160273, sqrt(pi) = 1.7724538509055160273 -- equal to every digit mpmath will print. |
Matched |
| =GAMMA(0) | Zero, which the page excludes | #NUM! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and the page's own example table lists '=GAMMA(0)' with the result #NUM!. The gamma function has a pole at 0. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMA(-2) | A negative integer, the other excluded case | #NUM! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and publishes '=GAMMA(-2)' with the result #NUM!. Gamma has poles at every non-positive integer. Asserted alongside GAMMA(-3.75), which is NOT an integer and must return a finite value -- together they check that an engine rejects the poles without rejecting the whole negative axis. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMA("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If Number contains characters that are not valid, GAMMA returns the #VALUE! error value." |
Matched |
Google Sheets (executed 2026-08-31 via Drive import)
Google Sheets is a rolling service with no pinnable version, so this run is identified by its date. The corpus was imported to Drive as .xlsx, recalculated by Sheets, and exported back for readback.
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMA(2.5),12) | Microsoft's first worked example | 1.329340388 | 1.329340388179ProvenanceMicrosoft publishes '=GAMMA(2.5)' with the result 1.329 ("Returns the gamma function value of 2.5 (1.329)"). Derived independently with mpmath at 50 decimal digits: Gamma(2.5) = 1.3293403881791370205, which rounds to the published 1.329 at the three decimals the page prints. Asserted at 12 dp rather than 3 because the page's precision is a display choice, not a limit on the answer, and 12 dp is well inside the ~15 significant digits an IEEE double carries. Cross-checked against the closed form the page itself supplies, Gamma(N+1) = N*Gamma(N): Gamma(2.5) = 1.5*Gamma(1.5) = 1.5*0.5*Gamma(0.5) = 0.75*sqrt(pi) = 1.32934038817913702, identical to 17 digits. |
Matched |
| =ROUND(GAMMA(-3.75),12) | Microsoft's second worked example: a negative non-integer argument | #NUM! | 0.267866128861ProvenanceMicrosoft publishes '=GAMMA(-3.75)' with the result 0.268. Derived independently with mpmath at 50 digits: Gamma(-3.75) = 0.26786612886141660256, which rounds to the published 0.268. This case matters because the gamma function is only defined for negative arguments by analytic continuation -- an implementation that simply integrates the defining integral cannot reach it -- and because the sign is a real test: Gamma is positive on (-4,-3), and an engine using the reflection formula with a sign slip lands on -0.268. |
Mismatch |
| =GAMMA(5) | At a positive integer n, GAMMA(n) is (n-1)! | 24 | 24ProvenanceDerived from the recurrence the page states, Gamma(N+1) = N*Gamma(N), together with Gamma(1) = 1: Gamma(5) = 4*3*2*1 = 24 = 4!. An exact integer, so this case is asserted with no ROUND wrapper at all and catches any accumulation of floating-point error in a series or Lanczos approximation. |
Matched |
| =ROUND(GAMMA(0.5)-SQRT(PI()),12) | The classical value Gamma(1/2) = sqrt(pi), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed-form value, and the reason it is asserted as a DIFFERENCE against the engine's own SQRT(PI()) is that it then tests the gamma implementation rather than the printing of a constant. mpmath at 50 digits: Gamma(0.5) = 1.7724538509055160273, sqrt(pi) = 1.7724538509055160273 -- equal to every digit mpmath will print. |
Matched |
| =GAMMA(0) | Zero, which the page excludes | #NUM! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and the page's own example table lists '=GAMMA(0)' with the result #NUM!. The gamma function has a pole at 0. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMA(-2) | A negative integer, the other excluded case | #NUM! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and publishes '=GAMMA(-2)' with the result #NUM!. Gamma has poles at every non-positive integer. Asserted alongside GAMMA(-3.75), which is NOT an integer and must return a finite value -- together they check that an engine rejects the poles without rejecting the whole negative axis. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMA("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If Number contains characters that are not valid, GAMMA returns the #VALUE! error value." |
Matched |
LibreOffice Calc 25.8.7.3 (tested 2026-08-31)
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMA(2.5),12) | Microsoft's first worked example | 1.329340388179 | 1.329340388179ProvenanceMicrosoft publishes '=GAMMA(2.5)' with the result 1.329 ("Returns the gamma function value of 2.5 (1.329)"). Derived independently with mpmath at 50 decimal digits: Gamma(2.5) = 1.3293403881791370205, which rounds to the published 1.329 at the three decimals the page prints. Asserted at 12 dp rather than 3 because the page's precision is a display choice, not a limit on the answer, and 12 dp is well inside the ~15 significant digits an IEEE double carries. Cross-checked against the closed form the page itself supplies, Gamma(N+1) = N*Gamma(N): Gamma(2.5) = 1.5*Gamma(1.5) = 1.5*0.5*Gamma(0.5) = 0.75*sqrt(pi) = 1.32934038817913702, identical to 17 digits. |
Matched |
| =ROUND(GAMMA(-3.75),12) | Microsoft's second worked example: a negative non-integer argument | 0.267866128861 | 0.267866128861ProvenanceMicrosoft publishes '=GAMMA(-3.75)' with the result 0.268. Derived independently with mpmath at 50 digits: Gamma(-3.75) = 0.26786612886141660256, which rounds to the published 0.268. This case matters because the gamma function is only defined for negative arguments by analytic continuation -- an implementation that simply integrates the defining integral cannot reach it -- and because the sign is a real test: Gamma is positive on (-4,-3), and an engine using the reflection formula with a sign slip lands on -0.268. |
Matched |
| =GAMMA(5) | At a positive integer n, GAMMA(n) is (n-1)! | 24 | 24ProvenanceDerived from the recurrence the page states, Gamma(N+1) = N*Gamma(N), together with Gamma(1) = 1: Gamma(5) = 4*3*2*1 = 24 = 4!. An exact integer, so this case is asserted with no ROUND wrapper at all and catches any accumulation of floating-point error in a series or Lanczos approximation. |
Matched |
| =ROUND(GAMMA(0.5)-SQRT(PI()),12) | The classical value Gamma(1/2) = sqrt(pi), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed-form value, and the reason it is asserted as a DIFFERENCE against the engine's own SQRT(PI()) is that it then tests the gamma implementation rather than the printing of a constant. mpmath at 50 digits: Gamma(0.5) = 1.7724538509055160273, sqrt(pi) = 1.7724538509055160273 -- equal to every digit mpmath will print. |
Matched |
| =GAMMA(0) | Zero, which the page excludes | #VALUE! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and the page's own example table lists '=GAMMA(0)' with the result #NUM!. The gamma function has a pole at 0. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Mismatch |
| =GAMMA(-2) | A negative integer, the other excluded case | #VALUE! | #NUM!ProvenanceExcel documents: "If Number is a negative integer or 0, GAMMA returns the #NUM! error value", and publishes '=GAMMA(-2)' with the result #NUM!. Gamma has poles at every non-positive integer. Asserted alongside GAMMA(-3.75), which is NOT an integer and must return a finite value -- together they check that an engine rejects the poles without rejecting the whole negative axis. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Mismatch |
| =GAMMA("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If Number contains characters that are not valid, GAMMA returns the #VALUE! error value." |
Matched |
Docs & syntax
- Excel (desktop): official documentation
- Google Sheets: official documentation
- LibreOffice Calc: official documentation