BY: Statistics Fundamentals Team
Reviewed By: Minsa A. (Senior Statistics Editor)

Factorial Calculator — Calculate n!

A factorial (written n!, read "n factorial") is the product of all positive integers from 1 up to and including n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By convention, 0! = 1. Factorials appear throughout mathematics, statistics, and probability — in permutation and combination formulas, the binomial distribution, and anywhere arrangements or selections need to be counted.

Factorial Calculator (n!)

Try:
Please enter a non-negative integer (0, 1, 2, …).
Result
—

What Is a Factorial?

The factorial of a non-negative integer n, written n! and read "n factorial," is the product of every positive integer from 1 through n. So 7! means 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040. The exclamation mark is the factorial symbol — sometimes called "shriek" in British mathematical circles, or "bang" in computing contexts.

The growth rate is what makes factorials so interesting. The jump from 1! = 1 to 5! = 120 to 10! = 3,628,800 to 20! which exceeds 2.4 quintillion is super-exponential: each new factorial dwarfs the previous one. For comparison, ten raised to the power of 18 is a quintillion, and 20! already surpasses it. This explosive growth is exactly what makes factorials useful for counting arrangements — and why a calculator handles the arithmetic rather than a pencil.

A concrete way to think about it: if you have n different books on a shelf, n! tells you how many different orders you could arrange them. Five books can be arranged 120 ways. Ten books can be arranged 3,628,800 ways. This counting interpretation is at the heart of why factorials appear so often in statistics and probability.

Fun fact: Six weeks expressed in seconds equals 7 × 6 × 24 × 60 × 60 = 3,628,800 — which is exactly 10!.

Factorial Formula

There are two mathematically equivalent ways to write the factorial formula. The first expresses it as a direct product; the second uses recursion. Both give the same answer, and the recursive form is what most programming languages and calculators use internally.

Product Form

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

Recursive Form

n! = n × (n−1)! Base case: 0! = 1

How to Calculate a Factorial — Step by Step

1
Identify n

Write down the non-negative integer you want to factorial. If n = 0, the answer is 1 by definition (see the section on 0! below).

2
Write the product

Starting from n, multiply by every integer counting down to 1: n × (n−1) × (n−2) × … × 2 × 1.

3
Multiply through

Work through the multiplications left to right, or use the recursive shortcut: n! = n × (n−1)!. A calculator handles this instantly.

4
Check your work

Verify against a known value. For example: 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 42 × 5 × 4 × 3 × 2 = 210 × 24 = 5,040.

Why Does 0! = 1?

Most students find 0! = 1 counterintuitive. The product of zero integers seems like it should be zero, not one. The good news is that this is not an arbitrary decision — four completely independent lines of reasoning all point to the same answer. Once you see them together, 0! = 1 stops feeling strange and starts feeling inevitable.

Reason 1 — Recursive Formula

The recursive definition says n! = n × (n−1)!. Set n = 1: 1! = 1 × 0!. We know 1! = 1, so 0! must equal 1 for the equation to hold. Without this, the recursive structure collapses entirely.

Reason 2 — Combinatorics

Factorials count arrangements. n! is the number of ways to arrange n distinct objects. For zero objects, there is exactly one arrangement — the empty arrangement. Do nothing, and you've done it one way. So 0! = 1.

Reason 3 — Empty Product

In mathematics, any product with no factors is defined as 1 (the multiplicative identity). This is the same convention that makes an empty sum equal to 0. Since 0! is a product over zero integers, it equals 1 by this rule.

Reason 4 — Gamma Function

The Gamma function extends factorials to real numbers. It satisfies Γ(n+1) = n! for non-negative integers. At n = 0: Γ(1) = ∫0∞ e−t dt = 1. So Γ(1) = 0! = 1 — the continuous extension agrees.

All four justifications — recursive formula, counting interpretation, empty product, and the Gamma function — independently give the same answer. 0! = 1 is the only consistent value.

Factorial Table (0 to 20)

The table below gives exact values for 0! through 20!, then scientific notation approximations for 50! and 100!. Notice that the table starts at n = 0 — the 0! = 1 row is real and mathematically meaningful, not a placeholder. Values above 20! require scientific notation because 20! already exceeds 2.4 × 1018. The calculator above computes any value you need instantly.

n n! (exact value)
01
11
22
36
424
5120
6720
75,040
840,320
9362,880
103,628,800
1139,916,800
12479,001,600
136,227,020,800
1487,178,291,200
151,307,674,368,000
1620,922,789,888,000
17355,687,428,096,000
186,402,373,705,728,000
19121,645,100,408,832,000
202,432,902,008,176,640,000
50≈ 3.041 × 1064
100≈ 9.333 × 10157

52! ≈ 8.07 × 1067 — the number of ways to shuffle a standard deck of cards. This number exceeds the estimated number of atoms on Earth.

Factorials in Statistics and Probability

This is the section most statistics students actually need. Every time you work with permutations, combinations, or the distributions below, a factorial sits underneath the calculation. The calculator above is a direct tool for these computations.

Permutations (nPr)

A permutation counts ordered arrangements — cases where the sequence matters. If you are choosing 1st, 2nd, and 3rd place from 7 runners, the order of the winners matters. The permutation formula divides out the arrangements you're not selecting:

nPr = n! / (n − r)!
Worked example: 7P3 = 7! / (7−3)! = 7! / 4! = 5,040 / 24 = 210 ordered arrangements.
See also: Permutation Calculator

Combinations (nCr) — The Binomial Coefficient

A combination counts unordered selections — cases where only the group matters, not the order. Choosing 3 students from a class of 7 gives the same group regardless of which name you pick first. The combination formula is also called the binomial coefficient, written as (n choose r):

nCr = n! / (r! × (n − r)!)
Worked example: 7C3 = 7! / (3! × 4!) = 5,040 / (6 × 24) = 35 ways.
See also: Combination Calculator

The Binomial Distribution

Every binomial probability calculation uses nCr, which means every binomial probability calculation uses a factorial. The binomial distribution probability mass function is:

P(X = k) = C(n,k) × pk × (1−p)n−k where C(n,k) = n! / (k!(n−k)!)
Example: Probability of exactly 3 heads in 5 coin flips = C(5,3) × 0.53 × 0.52 = [5!/(3!×2!)] × 0.125 × 0.25 = 10 × 0.03125 = 0.3125.

The Poisson Distribution

The Poisson distribution models the number of events in a fixed interval. Its probability mass function places k! in the denominator, which ensures the probabilities sum to 1 across all possible counts:

P(X = k) = (λk × e−λ) / k!

When k is large, Stirling's approximation (see below) makes Poisson probabilities easier to handle analytically. This connects factorials directly to the statistics and probability topics you're likely studying right now.

Factorials for Large Numbers — Stirling's Approximation

Computing n! exactly becomes impractical for large n because the numbers grow so fast. Stirling's approximation gives a close estimate using basic arithmetic. The correct formula is:

n! ≈ √(2πn) × (n/e)n

Where π ≈ 3.14159 and e ≈ 2.71828. For large n, the relative error shrinks rapidly toward zero.

Worked example for n = 10:
Exact: 10! = 3,628,800
Stirling: √(20π) × (10/e)10 ≈ 7.926 × 456,574 ≈ 3,618,000
Error: approximately 0.3% — extremely close for such a compact formula.

For n ≥ 100, the relative error drops below 0.01%. There is also a natural log form used in log-likelihood calculations and large-sample approximations in statistics:

ln(n!) ≈ n·ln(n) − n + (1/2)·ln(2πn)

This log form appears in Bayesian inference, in normal distribution approximations, and anywhere you need log-probability calculations with large factorials.

Trailing Zeros in n!

How many zeros appear at the end of n!? Each trailing zero comes from a factor of 10 = 2 × 5 within the product. Since factors of 2 always outnumber factors of 5, counting trailing zeros means counting factors of 5 in n!:

Trailing zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ⌊n/625⌋ + …

Add terms until they reach 0. The floor symbol ⌊ ⌋ means round down to the nearest integer.

100! trailing zeros: ⌊100/5⌋ = 20, ⌊100/25⌋ = 4, ⌊100/125⌋ = 0 → 24 trailing zeros.
50! trailing zeros: ⌊50/5⌋ = 10, ⌊50/25⌋ = 2 → 12 trailing zeros.

This question comes up regularly in discrete mathematics exams and competitive math problems. The pattern holds because every multiple of 5 contributes one factor of 5, and every multiple of 25 contributes an extra one, and so on.

Frequently Asked Questions

A factorial (written n!, read "n factorial") is the product of all positive integers from 1 up to and including n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120, and 10! = 3,628,800. By convention, 0! = 1. Factorials appear in combinatorics, probability, and statistics — whenever you need to count arrangements, permutations, or combinations.

Four independent reasons all give the same answer: (1) The recursive formula n! = n × (n−1)! requires it — for n=1: 1! = 1 × 0! = 1, so 0! must equal 1. (2) Combinatorics: there is exactly one way to arrange zero objects — the empty arrangement. (3) The empty product: a product with no factors equals 1 (the multiplicative identity). (4) The Gamma function: Γ(1) = 1, and since Γ(n+1) = n!, we get Γ(1) = 0! = 1. All four agree.

Two equivalent formulas: (1) Product form: n! = n × (n−1) × (n−2) × … × 2 × 1 — multiply all positive integers from n down to 1. (2) Recursive form: n! = n × (n−1)!, with base case 0! = 1 — each factorial equals n times the previous one. Both give the same result. The recursive form is what Python's math.factorial() and Excel's =FACT() use internally.

Factorials appear in four key places: (1) Permutations (ordered arrangements): nPr = n!/(n−r)!. (2) Combinations / binomial coefficient (unordered selections): nCr = n!/(r!(n−r)!). (3) Binomial distribution PMF: P(X=k) = [n!/(k!(n−k)!)] × pk × (1−p)n−k. (4) Poisson distribution PMF: P(X=k) = (λk × e−λ)/k!. Any time you compute permutations, combinations, or these distributions, you are computing a factorial.

100! (100 factorial) is approximately 9.333 × 10157 — a 158-digit number. It has exactly 24 trailing zeros (from ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24). The exact value is too long to display in full text, but the calculator at the top of this page computes it and displays it in proper scientific notation.

The standard factorial is defined only for non-negative integers (0, 1, 2, 3, …). The Gamma function extends factorials to most real numbers: Γ(n+1) = n! for non-negative integers, and Γ is defined for all complex numbers except the non-positive integers. So (1/2)! = Γ(3/2) = (√π)/2 ≈ 0.886. Factorials of negative integers (−1!, −2!, etc.) are undefined — the Gamma function has poles (undefined points) at z = 0, −1, −2, … (not just at negative integers — it is also undefined at zero).

Factorials connect directly to the core of statistics. The binomial distribution uses them in every probability calculation, the Poisson distribution carries k! in its denominator, and permutation and combination formulas are built entirely from factorial arithmetic. If you're working through the statistics and probability curriculum, this calculator is a tool you'll return to often. For quick lookup of key formulas and distributions, the statistics cheat sheet and statistics formulas pages are worth bookmarking alongside this one.


Explore More Calculators
M
Minsa A. Senior Statistics Editor, Statistics Fundamentals — View profile