Factorial Calculator
Enter n to get n! exactly (or in scientific form once it passes 170!), or switch to the double factorial n!! or the ratio n! ÷ k!.
Result
3,628,800
Scientific form
3.628800 × 10^6
Number of digits
7
log₁₀ of the result
6.5598
Stirling's approximation of n!
3.598696 × 10^6
Stirling error vs n!
-0.8296%
How it works
The factorial of a whole number n, written n!, is the product of every whole number from 1 up to n. It counts the ways to arrange n distinct things in a row, which is why it turns up in permutations, combinations, probability and series expansions. By definition 0! = 1: there is exactly one way to arrange nothing.
Factorials grow faster than any power. 10! is 3.6 million, 20! already has 19 digits, and 170! is the largest factorial a double-precision number can hold. Below that limit the calculator shows every digit exactly; above it the value is given in scientific form, worked out from the sum of the logarithms of the factors so nothing overflows.
The double factorial n!! multiplies every second number down from n (so 9!! = 9 × 7 × 5 × 3 × 1), and the quotient n! ÷ k! is the product of just the numbers from k + 1 to n. Multiplying only those factors, rather than forming two huge factorials and dividing, is how calculators keep 1,000! ÷ 998! = 999,000 from overflowing.
Stirling's approximation estimates n! without multiplying anything: n! ≈ √(2πn) × (n ÷ e)ⁿ. It is always a little low, but the relative error shrinks as n grows (about 0.8% at n = 10 and 0.08% at n = 100), which makes it the standard tool for factorials far too large to compute.
Formula
n! = n × (n − 1) × (n − 2) × … × 2 × 1 0! = 1 n!! = n × (n − 2) × (n − 4) × … 0!! = 1!! = 1 n! ÷ k! = (k + 1) × (k + 2) × … × n k ≤ n log₁₀(n!) = Σ log₁₀(i) for i = 1 … n (used once n! exceeds 2^1024) Stirling: n! ≈ √(2πn) × (n ÷ e)^n
Example
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800, a 7-digit number with log₁₀ = 6.5598. Stirling's approximation gives √(20π) × (10 ÷ e)¹⁰ = 3.598696 × 10⁶, which is 0.8296% below the true value.
The double factorial 9!! = 9 × 7 × 5 × 3 × 1 = 945, and 10!! = 10 × 8 × 6 × 4 × 2 = 3,840.
10! ÷ 7! = 10 × 9 × 8 = 720: the number of ways to award gold, silver and bronze among ten runners.
170! = 7.257416 × 10³⁰⁶ (307 digits) is shown in full. 171! = 1.241018 × 10³⁰⁹ is beyond double precision, so it is shown in scientific form only, with its 310 digits counted from log₁₀(171!) = 309.0938.
Assumptions and limitations
- n and k must be whole numbers from 0 to 100,000. Factorials of negative numbers and non-integers are not defined here (the gamma function extends them, but this calculator does not).
- Exact digits are shown while the result is below 2^1024 ≈ 1.797 × 10^308, the first value double precision cannot hold; 170! qualifies and 171! does not. Larger results are shown in scientific form with six decimal places, computed from the sum of the logarithms of the factors, and their digit count comes from that logarithm.
- Stirling's approximation is always evaluated for n! itself, even when you are calculating n!! or n! ÷ k!. At n = 0 the formula gives 0, so its error is shown as −100%.
- The double factorial follows the usual convention 0!! = 1 and (−1)!! = 1, so 1!! = 1 and 2!! = 2.
Frequently asked questions
Why is 0! equal to 1 and not 0?
Because n! counts arrangements and there is exactly one arrangement of an empty set. It is also the only value that keeps the pattern n! = n × (n − 1)! working at n = 1, since 1! = 1 × 0!. Every formula that uses factorials, from nCr to the Taylor series for eˣ, relies on 0! = 1.
Why does a spreadsheet give an error for 171! when this page gives an answer?
Spreadsheets and most programming languages store numbers in double precision, which tops out at about 1.797 × 10³⁰⁸. 170! is 7.26 × 10³⁰⁶ and fits; 171! is 1.24 × 10³⁰⁹ and does not. This calculator adds up the logarithms of the factors instead of multiplying them, so it can report the size and leading digits of any factorial up to 100,000!.
More in Math & Geometry calculators.