Math calculator

Factorial Calculator

Factorials with every digit exact, well past where a calculator gives up.

Factorial, every digit

Exact past where a double stops.

A whole number from 0 upwards, to 20,000.

20!

2,432,902,008,176,640,000

Digits

19

fits a double exactly

Trailing zeros

4

from the count of 5s, not by looking

Recurrence

20! = 20 × 19!

what forces 0! = 1

Stirling's estimate

2.422786847e+18

off by 0.416%

Where the trailing zeros come from

Legendre’s count of the factors of five, power by power
Multiples ofHow manyRunning total
544

Each trailing zero needs a 10, which needs a 2 and a 5. There are always more 2s than 5s in a factorial, so counting the 5s counts the zeros — and a multiple of 25 supplies two of them, which is why the table has more than one row.

  • 20! = 20 × 19!, which is the recurrence the whole thing rests on. Read it backwards to the bottom and it forces 0! = 1.
  • 20! ends in 4 zeros, and that count comes from Legendre's formula rather than from looking at the digits. Each trailing zero needs a 10, which needs a 2 and a 5 — and there are always more 2s than 5s, so the 5s are what limits it.
  • Factorials outgrow exponentials. 2^20 is 1.04858e+6 while 20! has 19 digits — and the gap widens at every step, because multiplying by n beats multiplying by 2 as soon as n passes 2.

Computed on whole numbers of unlimited size — every digit above is exact, not an approximation.

What this tool shows

20! is the largest factorial that fits a JavaScript number. This is computed on whole numbers of unlimited size, so all 158 digits of 100! are real rather than sixteen and an exponent.

  • Exact factorials up to 20,000
  • The digit count, and where a double gives up
  • Trailing zeros by Legendre’s formula
  • Why 0! is 1, by two independent arguments
  • Stirling’s approximation and its actual error
  • How fast factorials outgrow exponentials
Every digit exact Zeros from Legendre, not counted 0! answered, not asserted Stirling with its error

Exact on integers; approximations labelled as such.

Updated 7 September 2026 · Works in any browser, no installation

n! is the product of every whole number from 1 to n, and 0! is 1. That last one is not a convention: the recurrence n! = n × (n−1)! read backwards gives 1! = 1 × 0!, so 0! must be 1. Counting says the same — there is exactly one way to arrange nothing. 20! is the largest that fits a normal calculator; everything here is computed on whole numbers, so 100!’s 158 digits are all real.

At a glance

Formula shown
n! = n \u00d7 (n\u22121) \u00d7 \u2026 \u00d7 1, with 0! = 1. Trailing zeros = \u230an/5\u230b + \u230an/25\u230b + \u230an/125\u230b + \u2026 (Legendre). Stirling: n! \u2248 \u221a(2\u03c0n) \u00b7 (n/e)\u207f.
Scenario support
Counting arrangements of a set; computing a binomial coefficient by hand; checking how many digits a combinatorial answer will have.
Educational estimate
Planning support from the values you enter — not professional advice.

Why 0! is 1

Two independent arguments, and neither is “by convention”.

The recurrence. n! = n × (n−1)! is what defines a factorial. Read it at n = 1: 1! = 1 × 0!. Since 1! is 1, 0! has to be 1. Anything else breaks the definition at its very first step.

The counting. n! counts the orderings of n things. There is exactly ONE way to arrange nothing — the empty arrangement. Zero ways would mean the empty list cannot exist.

It is also what makes C(n, 0) = 1 come out right, and the binomial theorem, and every power series whose first term has a 0! in the denominator.

Counting the trailing zeros

100! ends in 24 zeros, and you can know that without computing 100!.

Every trailing zero needs a factor of 10, which needs a 2 and a 5. Factorials contain far more 2s than 5s, so the 5s are the limit. Count them: 20 multiples of 5 below 100, plus 4 more from the multiples of 25, which each contribute a second 5. That is 24.

This is Legendre’s formula, and the page shows the sum row by row. It works at any size — 1000! ends in 249 zeros by the same argument — and it is genuinely faster than looking, because it never builds the number.

Where a double gives up

20! is 2,432,902,008,176,640,000, which fits a JavaScript number exactly. 21! does not: it is the first factorial a double gets wrong.

Past that, floating point gives you about seventeen correct digits and an exponent. 100! shows as 9.33262154439441e+157, which is right to sixteen figures and silent about the other 142.

This page computes on integers of unlimited size, so every digit is real. It also reports the digit count, which is often the number you actually wanted — nobody needs all 2568 digits of 1000!, but knowing there are 2568 is useful.

Stirling’s approximation

n! ≈ √(2πn) × (n/e)ⁿ. It looks like an odd formula and it is remarkably good: about 8% off at n = 1, under 1% by n = 10, and under 0.1% by n = 100.

The relative error shrinks like 1/(12n), so the approximation gets better exactly where the exact computation gets harder. That is why it is the tool of choice in analysis and in algorithm cost estimates.

This page shows the approximation and the percentage it is actually off by, side by side with the exact value. An approximation quoted without its error is not much of an answer.

How fast they grow

Factorials outgrow every exponential. 2ⁿ doubles at each step; n! multiplies by n, and n keeps getting bigger.

At n = 10 they are already far apart: 2¹⁰ is 1024 and 10! is 3,628,800. By n = 100 the gap is 128 digits.

It is why brute-forcing an ordering is hopeless. Fifteen items have over a trillion arrangements; twenty have two and a half quintillion. Any algorithm that tries them all stops being usable somewhere around n = 12.

What factorials count

Arrangements. n! is the number of ways to order n distinct things. Five books on a shelf: 120 orders.

Combinations. C(n, k) = n!/(k!(n−k)!) counts choices where order does not matter. In practice nobody computes it that way — theBinomial Coefficient Calculator uses the multiplicative form, which never builds a factorial at all.

Series. eᵙ, sin x and cos x all have factorials in their denominators. It is why those series converge so quickly: the denominators outrun anything the numerators do.

Sources and methodology

Factorials, Legendre’s formula and Stirling’s approximation are all classical results.

Method. The product is computed on BigInt, so the result is exact at any size. The trailing-zero count is not read off the digits: it is Legendre’s sum of ⌊n/5^k⌋, which is why it is available even for values too large to display. Stirling’s approximation is computed in floating point and reported with the percentage error it actually made, rather than being presented as an answer. That engine is verified on every change against 68 hand-written assertions, including that every factorial to four hundred matches an independently written BigInt product and that the trailing-zero count matches a separately computed Legendre sum. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Binomial Coefficientn choose k exactly on big integers, by the multiplicative formula that divides as it goes and never builds a factorial — with Pascal's rule and permutations beside it.
ExponentPowers with the awkward cases right — a negative exponent is a reciprocal not a sign, a fractional one is a root, and zero to the zero is reported as contested.
Prime FactorizationBreak any number into primes with the division ladder shown, the number of trial divisions reported, and the argument for why the search can stop at the square root.
Gamma FunctionGamma, log-gamma, digamma and beta with the factorial shift stated every time, values reconstructed past the double overflow, and the poles explained through the reflection formula.
LogLogarithms in any base with the exponential form beside them, whole answers confirmed by raising the base back, and change of base worked through.
Power SetList all 2^n subsets with the binary word that generates each one, grouped by size and checked against the binomial coefficients, with the element-versus-subset distinction spelled out.

More in Math, or browse all calculators.

Read the guide

Factorials usually appear on the way to a binomial coefficient, and the Binomial Coefficient Calculator computes those WITHOUT building the factorials — which is why it handles C(200, 100) instantly where the factorial route would not. The Gamma Function Calculator extends factorials to non-integers.

Educational use disclaimer

This is an educational tool. Every digit shown is exact; Stirling’s approximation is clearly labelled as an approximation and its error is reported.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (3 updates)

Published 7 September 2026

  1. Published the factorial page on BigInt: 20! is the largest that fits a double, so every digit of 100!'s 158 is real here rather than sixteen and an exponent.
  2. The trailing-zero count comes from Legendre's formula rather than from scanning the digits, which is why it is available for values far too large to display.
  3. 0! = 1 is answered twice — by the recurrence and by the counting argument — rather than called a convention, because 'convention' is not an answer to the commonest question about factorials.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.