Core answer: n! = n × (n−1) × … × 2 × 1 counts the ways to arrange n distinct items in order: 3! = 6, 4! = 24, 5! = 120, 10! = 3,628,800. By convention 0! = 1 (one way to arrange nothing). Factorials grow faster than exponentials — 20! ≈ 2.4×10¹⁸, already beyond 64-bit integers.

Why factorial counts arrangements

Lining up 4 people: 4 choices for the first spot, 3 for the next, 2, then 1 → 4 × 3 × 2 × 1 = 24 orders. Each choice is independent, so the counts multiply (the multiplication principle). This single idea builds permutations P(n,k) = n!/(n−k)! and combinations C(n,k) = n!/(k!(n−k)!).

Growth table (respect the explosion)

nn!Scale
5120a small meeting
103.6 Ma city's population
136.2 B~Earth's people
202.4×10¹⁸grains of sand on a beach
528×10⁶⁷card shuffles — more than atoms in the Milky Way

A properly shuffled deck has almost certainly never existed in that order before in history.

Stirling's approximation (for big n)

n! ≈ √(2πn) × (n/e)ⁿ. Accurate to ~1% already at n = 10, and the only sane way to estimate 100! (≈ 9.33×10¹⁵⁷) or compute with logs: ln(n!) ≈ n ln n − n.

Worked examples

Example 1 — Seating arrangements. 6 guests at a round table: fix one person (rotations are identical) → (6−1)! = 120 arrangements.

Example 2 — Password space. A 4-digit PIN using 4 distinct digits from 0–9: P(10,4) = 10!/6! = 5,040 possibilities.

Example 3 — Anagrams. "LEVEL" has 5!/(2!·2!) = 30 distinct arrangements — divide by repeats (two L's, two E's).

Common mistakes and myths

  1. "0! = 0" — no, 0! = 1; it's defined so C(n,n) = n!/(n!·0!) = 1 works.
  2. Factorials of negatives or fractions — undefined for negative integers; fractions use the Gamma function (0.5! = √π/2) — advanced territory.
  3. Underestimating growth — factorial beats 2ⁿ by n = 4 and beats n¹⁰⁰ eventually; brute-forcing 15-city traveling salesman (15! ≈ 1.3×10¹² routes) is already hopeless.
  4. Overflow blindness — 13! overflows 32-bit int, 21! overflows 64-bit; use big integers or logarithms in code.
  5. Double factorial confusion — n!! skips (7!! = 7×5×3×1 = 105), it is NOT (n!)!.