Skip to content
Omnikalc

Stirling approximation calculator: estimate n! and see how close it is

Enter n to get Stirling's approximation of n factorial, the corrected version, the exact value, the relative error and the number of digits.

Updated on
Your inputs

Value out of range

Results

Stirling approximation of n!

1,300,430,722,199

Stirling approximation with the 1 ÷ (12n) correction
1,307,655,337,323
Exact value of n!
1,307,674,368,000
Relative error of the basic approximation
0.554 %
Number of digits of n!
13

Factorials grow faster than almost anything else, so they are often replaced by an approximation. The Stirling approximation calculator takes a whole number n and gives Stirling’s estimate of n!, the corrected estimate, the exact value, the relative error and the number of digits.

How the calculation works

  • Enter a whole number n from 1 to 170.
  • The Stirling approximation is n! ≈ √(2πn) × (n ÷ e)ⁿ. It replaces the product of n numbers with a smooth formula.
  • A more accurate version multiplies the result by (1 + 1 ÷ (12n)), which cuts the error to a small fraction of its size.
  • The calculator compares both with the exact value and shows the relative error of the basic formula and the number of digits of n!.

Example

For n = 15 the exact value is 15! = 1,307,674,368,000. Stirling gives √(30π) × (15 ÷ e)¹⁵ ≈ 1,300,430,722,199, which is 0.554 % too low. With the 1 ÷ 180 correction, the estimate is about 1,307,655,000,000, and the number has 13 digits.

Why it matters

Students of probability, statistics and statistical physics meet Stirling’s formula often. Seeing the estimate next to the exact value shows how quickly it becomes accurate and why it works so well for the huge numbers in those fields. It is also a good way to build intuition about how fast factorials grow, since each step multiplies the result by a larger number. It is also a good way to build intuition about how fast factorials grow, since each step multiplies the result by a larger number.

Good to know

The approximation is asymptotic, so it improves as n grows but is poor for very small n. For exact work with moderate n, use the exact factorial. Values above about 170! overflow ordinary floating-point numbers, so this calculator stops there.

The Taylor series calculator uses factorials, and the combinations calculator uses factorials to count selections.

Frequently asked questions

What is Stirling's approximation?

It is a formula that estimates the factorial of a large number as the square root of 2πn times (n over e) to the power n. It was found by James Stirling and Abraham de Moivre in the 18th century and is accurate to better than 1 percent from n = 10.

Why is it useful?

Exact factorials grow so fast that they overflow a calculator or a program, and they are hard to handle in proofs. Stirling's formula gives a smooth expression that is easy to manipulate, which is why it is used for entropy in physics, binomial probabilities and the analysis of algorithms.

How accurate is it?

The relative error is about 1 ÷ (12n), so 0.83 percent at n = 10 and 0.08 percent at n = 100. Adding the correction factor 1 + 1 ÷ (12n) makes the error shrink roughly with 1 over n squared.

Does it work for n = 0 or non-integers?

The formula is meant for large positive numbers. At n = 0 it is not defined, and for small n the error is large. The related gamma function extends the factorial to non-integers, and Stirling's series applies to that as well.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.