Stirling Approximation Calculator

Stirling approximation of 10!3,598,696
Exact factorial3,628,800
Relative error-0.83%
Digits in the exact value7
How this was calculated
  1. Stirling: n! ≈ √(2πn) × (n/e)^n with n = 10: √62.83 × (10 / 2.7183)^10.
  2. That gives 3,598,695.62; the exact factorial is 3,628,800.
  3. Relative error = -0.83% — the leading term of the error is 1/(12n) = 0.83%, which is why the approximation tightens as n grows.
  4. log10 of the approximation is 6.56, so the factorial has 7 digits.

This Stirling approximation calculator estimates the factorial of any positive integer n using Stirling's approximation: n! ≈ √(2πn) × (n/e)^n. It is the leading term of the asymptotic series in section 5.11 of the NIST Digital Library of Mathematical Functions. The approximation always slightly underestimates the factorial, and the relative error is dominated by the term 1/(12n): about 0.83% at n = 10, 0.17% at n = 50 and 0.08% at n = 100, matching the verified errors almost exactly. For n = 10 the approximation gives 3,598,696 against the exact 3,628,800 — an error of only -0.83%. For n = 50 the approximation gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. For n = 100 the approximation gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%.

Stirling's approximation is the accepted standard for estimating large factorials because it is simple, accurate, and reliable. Factorials outgrow ordinary calculator arithmetic quickly: 170! is about 7.26e306, near the top of double precision, which is why this calculator works in logarithms internally. Multiplying by exp(1/(12n)), the next term of the series, removes most of the remaining error. This page shows the formula, step-by-step workings, worked examples and sources.

Worked examples

Ten factorial

Primary result: 3,598,696 — against the exact 3,628,800 the error is already only -0.83%. (10)

Stirling approximation of 10!3,598,696
Exact factorial3,628,800
Relative error-0.83%
Digits in the exact value7

A hundred factorial

Primary result: 9.32e+157 — the exact value is 9.33e+157, an error of -0.08%. (100)

Stirling approximation of 100!9.32e+157
Exact factorial9.33e+157
Relative error-0.08%
Digits in the exact value158

Fifty factorial

Primary result: 3.04e+64 — error -0.17%, right on the 1/(12n) trend. (50)

Stirling approximation of 50!3.04e+64
Exact factorial3.04e+64
Relative error-0.17%
Digits in the exact value65

Why approximate a factorial?

Factorials explode in size faster than almost any other function in mathematics. A number like 100! has 158 digits, far too many for ordinary calculator arithmetic to handle directly. In 1730, the Scottish mathematician James Stirling found a smooth formula that tracks these values without requiring you to multiply every integer from 1 to n. That formula is n! ≈ √(2πn) × (n/e)^n, and it is the leading term of the asymptotic series in section 5.11 of the NIST Digital Library of Mathematical Functions. A Stirling approximation calculator uses this relationship to estimate factorials that would otherwise be impossible to compute with standard tools.

The accuracy of the approximation improves as n grows, and it always slightly underestimates the factorial. For n = 10 the approximation gives 3,598,696 against the exact 3,628,800, an error of only -0.83%. For n = 50 the approximation gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. For n = 100 the approximation gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%. The relative error is dominated by the term 1/(12n): about 0.83% at n = 10, 0.17% at n = 50 and 0.08% at n = 100, matching the verified errors almost exactly.

Because the approximation always slightly underestimates the factorial, you can sharpen it further by multiplying by exp(1/(12n)), which is the next term of the series. This adjustment removes most of the remaining error. The fact that the error shrinks as n increases makes the formula especially valuable for large factorials, where exact computation becomes impractical or impossible.

Factorials outgrow ordinary calculator arithmetic quickly. The value 170! is about 7.26e306, near the top of double precision, which is why this calculator works in logarithms internally. By operating in log space, the tool can return results for inputs that would overflow a standard numeric format, giving you a practical estimate where direct multiplication would simply fail.

The Stirling formula

The Stirling formula expresses a factorial as an approximation built from two pieces: a square-root term and an exponential term. Written out, it says n! ≈ √(2πn) × (n/e)^n. The first piece, √(2πn), sets the overall scale and grows slowly. The second piece, (n/e)^n, is the dominant driver: it raises n to its own power and divides by e raised to that same power. Together they capture the essential shape of the factorial. This expression is the leading term of the asymptotic series documented in section 5.11 of the NIST Digital Library of Mathematical Functions, and it is the core calculation behind every Stirling approximation calculator.

To see how close the formula comes, walk through the verified case of n = 10. The exact value of 10! is 3,628,800. Plugging n = 10 into the Stirling formula gives 3,598,696. The approximation is slightly lower than the exact factorial, with an error of only -0.83%. That gap is small enough for many practical uses, and it shrinks as n grows. For n = 50 the formula gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. For n = 100 it gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%.

The relative error follows a simple pattern: it is dominated by the term 1/(12n). At n = 10 this term is about 0.83%, at n = 50 it is about 0.17%, and at n = 100 it is about 0.08%, matching the verified errors almost exactly. The approximation always slightly underestimates the factorial. Multiplying by exp(1/(12n)), the next term of the series, removes most of the remaining error. Factorials outgrow ordinary calculator arithmetic quickly: 170! is about 7.26e306, near the top of double precision, which is why this calculator works in logarithms internally.

Worked examples

The three verified cases below show how closely the leading term of the asymptotic series approximates the exact factorial. The Stirling approximation calculator applies the formula n! ≈ √(2πn) × (n/e)^n, which is the leading term of the asymptotic series in section 5.11 of the NIST Digital Library of Mathematical Functions. At n = 10 the approximation gives 3,598,696 against the exact 3,628,800 — an error of only -0.83%. At n = 50 the approximation gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. At n = 100 the approximation gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%.

The relative error is dominated by the term 1/(12n): about 0.83% at n = 10, 0.17% at n = 50 and 0.08% at n = 100, matching the verified errors almost exactly. The approximation always slightly underestimates the factorial; multiplying by exp(1/(12n)) (the next term of the series) removes most of the remaining error. This is why the gap between the approximation and the exact value shrinks steadily as n grows, and why the formula becomes increasingly reliable for large inputs.

Factorials outgrow ordinary calculator arithmetic quickly: 170! is about 7.26e306, near the top of double precision, which is why this calculator works in logarithms internally. Handling the computation in log space avoids overflow and preserves the precision needed to report the approximation and its error accurately, even for values of n that would exceed the limits of standard floating-point arithmetic.

nApproximationExact valueError
103,598,6963,628,800-0.83%
503.04e+643.04e+64-0.17%
1009.32e+1579.33e+157-0.08%

The 1/(12n) error rule

The most useful feature of Stirling's approximation is that its error follows a simple, predictable pattern. The relative error is dominated by the term 1/(12n), meaning you can estimate how far off the approximation will be before you even calculate it. For n = 10, the rule predicts an error of about 0.83%, and the verified numbers confirm this: the approximation gives 3,598,696 against the exact 3,628,800, an error of only -0.83%. The match is almost exact.

The same pattern holds as n grows. For n = 50, the 1/(12n) rule predicts an error of about 0.17%, and the verified approximation gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. For n = 100, the rule predicts about 0.08%, and the approximation gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%. In every case, the 1/(12n) estimate lines up with the verified errors almost exactly, which is why a Stirling approximation calculator can give you a reliable sense of accuracy without computing the full factorial.

The approximation always slightly underestimates the factorial, so the error is always negative. You can remove most of this remaining error by multiplying the result by exp(1/(12n)), which is the next term of the asymptotic series in section 5.11 of the NIST Digital Library of Mathematical Functions. This refinement is especially useful when you need more precision but still want to avoid computing enormous factorials directly. Factorials outgrow ordinary calculator arithmetic quickly — 170! is about 7.26e306, near the top of double precision — which is why this calculator works in logarithms internally.

Where Stirling's formula is used

Factorials grow so fast that they overflow ordinary calculator arithmetic almost immediately. The value 170! is about 7.26e306, near the top of double precision, so any practical Stirling approximation calculator works in logarithms internally. By computing log(n!) instead of n!, the calculator can handle values of n far beyond what direct multiplication allows. Stirling's approximation, n! ≈ √(2πn) × (n/e)^n, is the leading term of the asymptotic series in section 5.11 of the NIST Digital Library of Mathematical Functions, and it is particularly convenient in log space because it turns products and powers into simple sums.

The same asymptotic series applies to the gamma function, which extends the factorial to non-integer arguments. This connection, documented in DLMF 5.11, means the approximation is not limited to whole numbers. Researchers evaluating gamma for large or non-integer inputs rely on the same leading term, and the accuracy improves steadily as the argument grows. The relative error is dominated by the term 1/(12n): about 0.83% at n = 10, 0.17% at n = 50, and 0.08% at n = 100. Verified calculations confirm this pattern: for n = 10 the approximation gives 3,598,696 against the exact 3,628,800, an error of only -0.83%. For n = 50 it gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. For n = 100 it gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%.

The approximation always slightly underestimates the factorial. Multiplying by exp(1/(12n)), which is the next term of the series, removes most of the remaining error. This makes the formula reliable enough for work where exact factorials are impractical to compute directly.

In statistics, Stirling's formula earns its keep in problems involving large combinatorial counts, likelihood evaluations, and entropy calculations, where log-space computation is standard practice. In physics, it appears in statistical mechanics derivations, where factorials of huge particle counts arise and only logarithmic values are needed. Because the relative error shrinks as n grows, the approximation is most accurate exactly where exact computation becomes most difficult.

The relative error is governed by 1/(12n), so the approximation improves as n grows: 0.83% at n = 10, 0.17% at n = 50, and 0.08% at n = 100. It always underestimates, and multiplying by exp(1/(12n)) removes most of the remaining gap.

Limits of the approximation

Stirling's approximation is an asymptotic approximation, not an identity. The formula n! ≈ √(2πn) × (n/e)^n gives the leading term of the asymptotic series described in section 5.11 of the NIST Digital Library of Mathematical Functions. Because it is only the first term, the result never equals the factorial exactly. A Stirling approximation calculator is useful for estimating factorials that would otherwise be impossible to compute, but the output should be read as a close estimate rather than a precise value.

The approximation always slightly underestimates the factorial. The relative error is dominated by the term 1/(12n), which shrinks as n grows. At n = 10 the approximation gives 3,598,696 against the exact 3,628,800 — an error of only -0.83%. At n = 50 the approximation gives 3.04e+64 against the exact 3.04e+64, an error of -0.17%. At n = 100 the approximation gives 9.32e+157 against the exact 9.33e+157, an error of -0.08%. These verified errors match the 1/(12n) prediction almost exactly. Multiplying by exp(1/(12n)), the next term of the series, removes most of the remaining error.

The approximation is poor for tiny n. When n is small, the relative error is at its largest, and the gap between the estimate and the exact factorial becomes more noticeable in absolute terms. For applications that require an exact integer result — combinatorics, probability calculations, or any context where a specific factorial value must be known — the approximation is no substitute for computing the factorial directly.

Factorials outgrow ordinary calculator arithmetic quickly. The value 170! is about 7.26e306, near the top of double precision, which is why this calculator works in logarithms internally. Working in logarithms allows the tool to handle much larger values than direct multiplication could support, while still giving the user a usable estimate of the factorial's magnitude.

FAQs

What is Stirling's approximation formula?

Stirling's approximation formula is n! ≈ √(2πn) × (n/e)^n. For n = 10, it gives 3,598,696 against the exact 3,628,800. The approximation slightly underestimates the true factorial value, but the gap shrinks as n grows larger, making it increasingly useful for big values of n.

How accurate is Stirling's approximation?

It always slightly underestimates, by about 1/(12n). In verified cases, the error is -0.83% at n = 10 and -0.08% at n = 100. The approximation becomes more accurate as n increases, with the relative error shrinking roughly in proportion to 1/n, making it reliable for large values.

Why does this calculator stop at n = 170?

170! is roughly 7.26e306, close to the largest finite double. Beyond it the exact product overflows, while log-space methods keep working. The calculator uses standard floating-point arithmetic, which cannot represent numbers larger than approximately 1.8e308, so n = 170 marks the practical limit for exact factorial computation.

What is Stirling's approximation used for?

Before computers it made huge factorials computable by hand; today it underpins approximations in probability, statistical mechanics and algorithm analysis. It provides a tractable way to estimate factorials that would otherwise be impossible to calculate directly, making it essential in fields requiring large combinatorial calculations.

Can the approximation be improved?

Yes. Multiplying by exp(1/(12n)) corrects the leading error term. At n = 10 it closes most of the -0.83% gap. This correction targets the dominant source of underestimation, significantly improving accuracy without requiring the full exact factorial calculation, especially useful for moderate values of n.

Does Stirling's approximation work for small n?

No: the verified n = 10 case already errs by -0.83%, and at n = 1 the error is about -7.8%; it is a large-n tool. The approximation becomes reliable only as n grows, so for small values the exact factorial should be computed directly rather than estimated.

Sources

Related calculators

Factorial Calculator
Exact factorials up to 170! computed with arbitrary-precision integers — no scientific-notation rounding — with the digit count and trailing zeros (Legendre's formula) explained.
Permutation and Combination Calculator
nPr and nCr with and without repetition — permutations where order matters, combinations where it does not — with all four counts side by side.
Binomial Distribution Calculator
Exact, at-most and at-least probabilities for a run of independent yes/no trials — with the combination count, mean and standard deviation.