What is a factorial?
The factorial of a non-negative whole number n, written n! and read "n factorial", is the product of all whole numbers from 1 up to n: n! = 1 × 2 × 3 × ... × n. So 4! = 1 × 2 × 3 × 4 = 24, 5! = 120 and 6! = 720. The exclamation-mark notation was introduced by Christian Kramp in 1808, and the idea underneath it is counting: if you have n distinct items, there are n choices for the first position in a line, n − 1 for the second, n − 2 for the third, and so on down to a single choice for the last place. Multiplying those choices together gives n!, which is exactly the number of different orders — permutations — in which the items can be arranged.
Two special cases anchor the whole system. 1! = 1, a single item in a single order. And 0! = 1, not 0: there is exactly one way to arrange nothing, the empty arrangement. The recurrence n! = n × (n − 1)! makes the same point algebraically — working backwards from 1! = 1 forces 0! = 1, and that value is what makes the combination formula give sensible answers at its edges, such as choosing everything or choosing nothing from a set. A factorial calculator exists because the numbers explode so quickly: hand-multiplying to 20! means handling a 19-digit answer, and to 100! a 158-digit one, where a single slipped digit ruins everything downstream. This page multiplies exactly, shows every running product, and reports the digit count and trailing zeros so you can verify the answer at a glance.
How this factorial calculator works
For whole numbers the engine is deliberately simple and completely exact. JavaScript numbers are floating point and can only hold integers precisely up to 2^53, which 19! already exceeds — an ordinary calculator therefore rounds 20! silently. This page uses BigInt arithmetic instead: every multiplication is performed on whole numbers of unlimited size, so the 2,568-digit value of 1,000! is digit-for-digit correct, not an approximation dressed up as an answer. The multiplication steps table lists each running product for inputs up to 100, and for small inputs up to 25 the full expansion string, n × (n − 1) × ... × 1, is printed so the structure of the definition is visible, not hidden behind a single leap to the answer.
Two summary figures accompany every whole-number result. The digit count is the length of the exact value, and the trailing zeros count is computed independently by Legendre's rule — counting factors of 5 — so the two act as a cross-check on each other: if the exact product did not end in exactly that many zeros, something would be wrong. The page also reports the double factorial n!! and a scientific-notation form for very large results. Enter a decimal such as 0.5 or 3.5, or a negative non-integer such as −1.5, and the calculator switches to gamma mode automatically, says so plainly, and labels the result an approximation. Nothing is uploaded: all of this happens in your browser tab.
The factorial formula and how fast factorials grow
The definition can be written three equivalent ways. As a product: n! = 1 × 2 × 3 × ... × (n − 1) × n. As a recurrence: n! = n × (n − 1)! with 0! = 1, which is how the steps table above is built. And, for the gamma extension covered below, as Γ(n + 1). The growth implied by the product form is ferocious. Each step multiplies by a bigger number than the step before, so factorials outrun every fixed-base exponential: 2^n and even 10^n fall behind permanently once n is large, because the factorial's multiplier keeps growing while the exponential's stays fixed.
The landmark sizes are worth memorising as sanity checks. 10! = 3,628,800 — seven digits. 20! has 19 digits, 50! has 65 digits, 100! has 158 digits, 200! has 375 digits, 500! has 1,135 digits and 1,000! has 2,568 digits. For quick estimates of huge factorials, mathematicians use Stirling's approximation, n! ≈ √(2πn) × (n/e)^n, which is already within about 1% at n = 10 and gets relatively better as n grows. It is an estimate, however, not a value: this calculator never uses it for whole numbers, because exact multiplication is cheap at these sizes and an estimate cannot tell you a digit count or a trailing-zero count you can trust.
Worked examples: 5!, 20! and 100!
5! step by step. Start from 1 and multiply upwards: 1 × 2 = 2, 2 × 3 = 6, 6 × 4 = 24, 24 × 5 = 120. So 5! = 120, a three-digit answer. Its single trailing zero comes from the one factor of 5 in the product pairing with one of the plentiful factors of 2 to make a 10, matching Legendre's count of floor(5/5) = 1.
20! step by step. Continuing the same ladder past 10! = 3,628,800: multiply by 11 to get 39,916,800, by 12 for 479,001,600, and keep going through 15! = 1,307,674,368,000 until the final multiplication by 20 gives 20! = 2,432,902,008,176,640,000. Check the shape before trusting any source for this number: it must have 19 digits, and its trailing zeros must be floor(20/5) = 4 — count them: ...640,000 ends in exactly four zeros. A floating-point calculator will show 2.43290200817664 × 10^18, which throws away the last five digits entirely; the exact value matters when factorials feed into further exact arithmetic, such as probability fractions that later cancel.
100! and the limits of hand arithmetic. Nobody multiplies to 100! by hand reliably, which is the entire point of this tool. The exact answer has 158 digits and 24 trailing zeros (floor(100/5) + floor(100/25) = 20 + 4). The reference table below gives every factorial from 0! to 20! exactly; all of them were produced by the same multiplication this page performs, so you can reproduce any row by entering its number above.
| Factorial | Exact value | Digits |
|---|---|---|
| 0! | 1 | 1 |
| 1! | 1 | 1 |
| 2! | 2 | 1 |
| 3! | 6 | 1 |
| 4! | 24 | 2 |
| 5! | 120 | 3 |
| 6! | 720 | 3 |
| 7! | 5,040 | 4 |
| 8! | 40,320 | 5 |
| 9! | 362,880 | 6 |
| 10! | 3,628,800 | 7 |
| 11! | 39,916,800 | 8 |
| 12! | 479,001,600 | 9 |
| 13! | 6,227,020,800 | 10 |
| 14! | 87,178,291,200 | 11 |
| 15! | 1,307,674,368,000 | 13 |
| 16! | 20,922,789,888,000 | 14 |
| 17! | 355,687,428,096,000 | 15 |
| 18! | 6,402,373,705,728,000 | 16 |
| 19! | 121,645,100,408,832,000 | 18 |
| 20! | 2,432,902,008,176,640,000 | 19 |
Trailing zeros and digit counts
The trailing zeros of n! are one of the most common interview and exam questions in this area, and the trick is to never compute n! at all. A trailing zero is a factor of 10, and 10 = 2 × 5. In the product 1 × 2 × ... × n, even numbers supply factors of 2 in abundance, so factors of 5 are the bottleneck: every multiple of 5 contributes at least one, every multiple of 25 contributes a second, every multiple of 125 a third, and so on. This is Legendre's formula: zeros(n!) = floor(n/5) + floor(n/25) + floor(n/125) + ..., stopping when the power of 5 passes n.
Worked checks: 25! has floor(25/5) + floor(25/25) = 5 + 1 = 6 trailing zeros. 100! has 20 + 4 = 24. 1,000! has 200 + 40 + 8 + 1 = 249. This calculator runs Legendre's rule independently of the multiplication and displays the count next to the exact value, whose ending you can inspect for yourself — two routes to the same figure, agreeing. Digit counts work the opposite way: there is no elementary shortcut, which is why the honest method is the one used here — produce the exact integer and count its digits. Approximations such as Stirling's can predict a digit count, but only the exact product proves it, especially near boundaries where an estimate could be off by one.
Beyond whole numbers: the gamma function and double factorials
The product definition stops at whole numbers, but mathematics needs factorial-like values in between — in probability distributions, integrals and physics. The standard extension is the gamma function Γ(z), defined for positive values by an integral and extended to almost all other values by the recurrence Γ(z + 1) = zΓ(z). Its key property is that it agrees with the factorial on whole numbers: Γ(n + 1) = n! for every non-negative integer n. That justifies defining x! = Γ(x + 1) for decimals and negative non-integers, which is exactly what this calculator's gamma mode does.
The most famous value is 0.5! = Γ(1.5) = √π / 2 ≈ 0.8862269255, which is why half-integer factorials appear wherever the normal distribution does. Further examples: 2.5! ≈ 3.3233509704, 3.5! = Γ(4.5) ≈ 11.6317283966, and (−0.5)! = Γ(0.5) = √π ≈ 1.7724538509. Negative whole numbers are the exception: Γ has poles at 0, −1, −2, ..., so −1!, −2! and so on are genuinely undefined, and this page says so rather than inventing a number. Honesty note: gamma values here are computed with the Lanczos approximation, a numerical method accurate to roughly 15 significant digits. They are labelled approximate wherever they appear; integer factorials on this page are exact, and the two kinds of result are never blurred together.
The double factorial n!! is a different, purely whole-number idea: multiply every second number down from n, keeping n's parity. For even n, n!! = n × (n − 2) × ... × 2; for odd n, n!! = n × (n − 2) × ... × 1. So 6!! = 48, 7!! = 105, 8!! = 384 and 9!! = 945, with 0!! = 1!! = 1 by definition. Double factorials count perfect matchings and appear in integrals of powers of sine and cosine. Despite the notation, n!! is not (n!)! — that double application of the ordinary factorial is astronomically larger.
What factorials are used for
Permutations and combinations are the everyday home of factorials. Arranging r items chosen from n, where order matters, can be done in n! / (n − r)! ways; choosing r items from n where order does not matter can be done in n! / (r! × (n − r)!) ways — the binomial coefficient. These two formulas price everything from lottery odds and card hands to the number of possible passwords and the branching factor of a game tree, and both are only as trustworthy as the factorials inside them, which is why exact values matter once the numbers grow.
Beyond counting, factorials are built into the Taylor series that define e^x, sine and cosine — the denominators are factorials — and into the Poisson distribution in statistics, the gamma and beta distributions (which use Γ directly), and the volumes of high-dimensional spheres. In computing, n! is the standard worst case that makes brute-force ordering problems hopeless: a travelling-salesman search over just 20 cities faces 20! ≈ 2.4 × 10^18 routes, which is why algorithms, not bigger computers, solve such problems. Whenever a factorial appears in your own work, this page gives you the exact value, the digit count and the scale at a glance.
Common factorial mistakes
Writing 0! = 0. The single most common error. 0! = 1, by the empty-product definition and by the recurrence; using 0 breaks combination formulas at their edges. Confusing n!! with (n!)!. 4!! = 8, while (4!)! = 24! has 24 digits. The double factorial steps by twos; it does not apply the factorial twice. Adding instead of multiplying. Factorial is a product: 5! is 120, not 15. The related sum 1 + 2 + ... + n is a triangular number, a different object entirely.
Trusting a rounded display. Spreadsheets and pocket calculators switch to floating point early: 20! comes back as 2.43290200817664 × 10^18 with the final digits silently wrong, and by 171! they overflow to infinity altogether. If the last digits matter — for a check digit, an exact probability or a divisibility argument — use exact arithmetic like this page's. Taking factorials of negative whole numbers. They are undefined, full stop; only negative non-integers have gamma-mode values. Underestimating growth. Intuitions trained on doubling fail here: adding one more item to an ordering problem multiplies the work by the new count, so problems go from trivial to impossible within a few steps — 15! is already over a trillion.
Limits: the 1,000! cap and approximation honesty
The 1,000! cap is a page-design choice, stated openly rather than hidden: beyond a few thousand digits the result stops being readable, downloads become unwieldy, and almost no genuine school, exam or engineering task needs more. Within the cap, every integer result is exact BigInt arithmetic — no rounding, no scientific-notation substitution, no Stirling estimate. Gamma mode is the opposite bargain and is labelled as such: the Lanczos approximation delivers about 15 significant digits, far beyond practical need, but it is a numerical approximation, and the page marks it "approximate" in the headline, the note and the downloaded report. If a future version of this tool ever raises the cap, the same rule will apply: exact where exact is claimed, approximate only where labelled.
Sources and References
- Wolfram MathWorld - Factorial - definition, growth and identities
- Wolfram MathWorld - Gamma Function - the extension of the factorial used in gamma mode
- Wolfram MathWorld - Double Factorial - definition and values
- NIST Digital Library of Mathematical Functions - Chapter 5, Gamma Function - definitions and properties
- Math is Fun - Factorial - an accessible introduction with worked examples
- Wikipedia - Factorial - history, notation and applications
- OEIS A000142 - The factorial sequence, the reference values for n!
Every figure in this guide was calculated with this page's own method, so you can reproduce each one exactly by entering the same numbers above. All seven sources above were checked live while this page was written; no substitution was needed.