Statistical function

GAMMALN function

Returns the natural logarithm of the gamma function, a safe way to work with huge factorials without overflow.

Available in All versions of Excel, including Microsoft 365 and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

GAMMALN(x)
ArgumentWhat it means
xRequiredA positive number.

Returns: The value ln(Γ(x)).

How GAMMALN works

Factorials grow explosively: 171! is already too large for Excel, so =FACT(171) returns #NUM!. Taking logarithms tames the numbers. GAMMALN returns ln(Γ(x)), and because Γ(n+1) = n!, GAMMALN(n+1) is the natural log of n factorial. Logs turn products into sums and ratios into differences, so you can combine several giant factorials and convert back with EXP at the end.

This is how statisticians compute binomial and other probabilities with very large counts, and it is how you can check a COMBIN result for large inputs. Unlike GAMMA, GAMMALN only accepts positive inputs. GAMMALN.PRECISE is the newer name for the same calculation; both give identical results in current Excel.

Examples

1Log of 100 factorial

B2fx=GAMMALN(A2+1)
AB
1nln(n!)
2100363.7394

Result: 363.7394

100! has 158 digits, but its natural log is just 363.739376 (shown to 4 decimals). =EXP(B2) would turn it back into 9.3326E+157.

2Ratio of two big factorials

D2fx=EXP(GAMMALN(B2+1)-GAMMALN(B3+1))
ABCD
1ItemValue
2n1009900
3k98

Result: 9900

100!/98! = 100 × 99 = 9,900. Subtracting the logs and applying EXP returns 9900.000000, which Excel displays as 9900 in General format. The same trick works when the factorials themselves would overflow.

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

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!x is 0 or negative.GAMMALN needs a positive argument; for negative non-integers use =LN(ABS(GAMMA(x))).
#VALUE!x is text.Make sure the cell contains a number.

Tips

  • GAMMALN(n+1) = LN(FACT(n)) for whole n, but keeps working long after FACT overflows.
  • Results of EXP(GAMMALN(...)) can carry tiny floating-point noise; wrap them in ROUND when you expect a whole number.

Google Sheets

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

GAMMALN 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
DutchGAMMA.LN
FrenchLNGAMMA
ItalianLN.GAMMA
PolishROZKŁAD.LIN.GAMMA
Portuguese (Brazil)LNGAMA
Portuguese (Portugal)LNGAMA
RussianГАММАНЛОГ
SpanishGAMMA.LN
TurkishGAMALN