Factorial (n!) Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Factorial calculator: what it computes

The factorial of a non‑negative integer n, written n!, is the product of all whole numbers from 1 up to n. This page computes exact factorial values in your browser using BigInt, so results are not rounded (within practical performance limits).

Quick definition

For integers n ≥ 1:

n! = n × (n − 1) × (n − 2) × … × 2 × 1

And by convention:

0! = 1 (the “empty product”).

Formula: MathML (product form)

n!= k=1 n k

Recursive form (useful for reasoning)

Factorials satisfy:

n! = n × (n − 1)!, with 0! = 1.

How to use this factorial calculator

  1. Enter a whole number n ≥ 0.
  2. Select Compute Factorial (or press Enter).
  3. Review the outputs: the exact value of n! and the number of digits.
  4. Use Copy Result to copy the factorial value to your clipboard.

This tool is intentionally limited to standard factorials for non‑negative integers. If you need “factorials” of decimals or negative numbers, that’s typically the Gamma function, which is not computed here.

Factorials grow extremely fast. Even modest inputs produce very large integers:

That rapid growth is exactly why factorials appear in counting and probability problems: they count how many ways to arrange or choose items.

Worked example: computing and reading 6!

Suppose you want to compute 6!.

By the definition:

6! = 6 × 5 × 4 × 3 × 2 × 1 = 720

Interpretation: if you have 6 distinct objects (for example, 6 different books), there are 720 different possible orderings.

The same number feeds directly into combinatorics. How many ways can you pick 2 of those 6 books to take on a trip, ignoring order? C(6, 2) = 6! ÷ (2! × 4!) = 720 ÷ (2 × 24) = 15. Enter 6 above and the calculator reports the exact value 720, a digit count of 3, and 1 trailing zero (from the single factor of 5 in the product 6 × 5 × 4 × 3 × 2 × 1). Enter 100 and it reports 158 digits, 24 trailing zeros, and an approximate scientific form of 9.332 × 10¹⁵⁷.

Common factorial values (and digit counts)

This table is helpful for sanity‑checking results and understanding growth.

n n! Digits in n! Notes
0 1 1 Defined as the empty product
1 1 1 Same value as 0!
5 120 3 Small counting problems
10 3,628,800 7 Already in the millions
20 2,432,902,008,176,640,000 19 Exceeds 64‑bit integer range
50 30,414,093,201,713,378,043,612,608,166,064,768,844,377,641,568,960,512,000,000,000,000 65 Large but still commonly referenced
100 93,326,215,443,944,152,681,699,238,856,266,700,490,715,968,264,381,621,468,592,963,895,217,599,993,229,915,608,941,463,976,156,518,286,253,697,920,827,223,758,251,185,210,916,864,000,000,000,000,000,000,000,000 158 Often used in examples; huge integer

Introduction: Why factorials matter (common uses)

Permutations (arrangements)

If you have n distinct items and want to count how many different orderings exist, the answer is n!.

Combinations (choosing without order)

The number of ways to choose r items from n items is:

C(n, r) = n! / (r!(n − r)!)

That’s why factorials show up constantly in probability, statistics, and counting problems.

Series expansions (why n! appears in calculus)

Factorials appear in power series; for example, the exponential function can be written as:

ex = Σ (xn / n!) for n = 0 to .

Estimating size: Stirling’s approximation and digit counts

When you only need the magnitude of a factorial rather than its exact digits, Stirling’s approximation is the standard tool:

n! 2πn ( ne ) n

Already at n = 10 the approximation gives 3,598,696 against the true 3,628,800 — an error under 1 percent that keeps shrinking as n grows. Taking base-10 logarithms turns it into a digit-count predictor: the number of digits of n! is ⌊log₁₀(n!)⌋ + 1, and log₁₀(n!) ≈ n⋅log₁₀(n/e) + ½⋅log₁₀(2πn). For n = 100 this predicts 157.97, matching the true 158 digits. This is exactly how the calculator’s approximate scientific notation stays honest even when the exact integer runs to thousands of digits.

Why factorials end in zeros (Legendre’s formula)

Every trailing zero of n! is a factor of 10 = 2 × 5, and since factors of 2 are plentiful, the fives are the bottleneck. Legendre’s formula counts them:

Z (n) = i=1 n 5i

For n = 100: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 trailing zeros, which you can confirm in the result panel. The sum is finite in practice because terms vanish once 5i > n. Interviewers love this one, and it is a good sanity check that a huge factorial result is correct: wrong arithmetic almost never lands on exactly the right zero count.

Plain-text formula: n! = n × (n − 1) × … × 2 × 1 with 0! = 1; digits(n!) = floor(log10(n!)) + 1; Stirling: n! ≈ √(2πn) × (n/e)ⁿ; trailing zeros Z(n) = ∑ floor(n/5ⁱ) for i = 1, 2, …; scientific form shown as first digits × 10^(digits − 1).

Source/version metadata: exact values computed client-side with JavaScript BigInt (arbitrary-precision integers, no rounding); Stirling’s approximation and Legendre’s formula are classical results found in any combinatorics text (e.g., Graham, Knuth & Patashnik, Concrete Mathematics, ch. 4). Input capped at n = 5,000 for responsiveness. Last reviewed July 2026.

Limitations and assumptions (important)

Factorial questions students actually ask

What is 0! and why is it 1?

0! = 1 by convention, as the empty product: multiplying no numbers at all leaves the multiplicative identity, 1. The convention also keeps formulas consistent — C(n, 0) = n!/(0! n!) must equal 1, and the power series for eₓ needs its first term to be x⁰/0! = 1.

Why do factorials grow so fast?

Each step multiplies by a progressively larger integer, so the growth rate itself keeps accelerating. Stirling's approximation shows n! grows like (n/e)ⁿ, which outpaces any exponential cⁿ with fixed base c. In digit terms: 10! has 7 digits, 100! has 158, and 1,000! already has 2,568.

Can this calculator compute factorials of decimals or negative numbers?

No. The standard factorial is defined only for whole numbers n ≥ 0, and this tool computes it exactly with BigInt arithmetic. The continuous extension to decimals is the Gamma function, Γ(n) = (n − 1)! at positive integers, which needs floating-point methods and is deliberately out of scope here.

What is the largest n this page can compute?

The input is capped at n = 5,000, which produces an exact integer of 16,326 digits in well under a second on a modern device. The cap exists because rendering and copying tens of thousands of digits, not the multiplication itself, is what slows browsers down.

Why do large factorials end in so many zeros?

Every trailing zero comes from a factor of 10 = 2 × 5, and factors of 5 are scarcer than factors of 2, so the zero count equals the number of fives in the product: floor(n/5) + floor(n/25) + floor(n/125) + … For 100! that gives 20 + 4 = 24 trailing zeros, which this calculator reports for every result.

Enter a whole number ≥ 0. For responsiveness, this calculator limits n to 5,000.

Status messages will appear here.

Enter a value to see n!
Status messages will appear here.

Arcade Mini-Game: Factorial (n!) Calculator Calibration Run

Use this quick arcade run to practice separating useful scenario inputs from common planning mistakes before you rely on the calculator output.

Score: 0 Timer: 30s Best: 0

Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.