Factorial Guide

What do I need to know about Factorials and Counting?

n! = n × (n−1) × (n−2) × ... × 2 × 1. 0! = 1 (by convention — one way to arrange nothing). Key values: 5! = 120. 10! = 3,628,800. 20! = 2.43×10¹⁸. 52! = 8.07×10⁶⁷ (more than atoms in the observable universe). Factorials grow faster than any polynomial or exponential function. Stirling's approximation (accurate for large n): n! ≈ √(2πn) × (n/e)ⁿ. For n=10: exact = 3,628,800. Stirling: √(62.83) × (10/2.718)¹⁰ = 7.926 × 3,598,696 ≈ 3,598,600. Error: 0.83%.

What should I know about Double Factorial?

Double factorial n!! = n × (n−2) × (n−4) × ... down to 1 or 2. For even n: n!! = n × (n−2) × ... × 4 × 2. For odd n: n!! = n × (n−2) × ... × 3 × 1. Examples: 6!! = 6 × 4 × 2 = 48. 7!! = 7 × 5 × 3 × 1 = 105. Note: n!! ≠ (n!)! — it does NOT mean the factorial of factorial n. Wallis product: relates double factorials to π: π/2 = (2·4·6·8·...)/( 1·3·5·7·...) = (2·2·4·4·6·6·...)/(1·3·3·5·5·7·...) Double factorials appear in probability distributions and integration of trigonometric functions.

What's the key thing to understand about Subfactorials and Derangements?

A derangement is a permutation where NO element appears in its original position. !n = n! × Σ(k=0 to n) (-1)^k/k! ≈ n!/e. !0 = 1, !1 = 0, !2 = 1, !3 = 2, !4 = 9, !5 = 44. Classic problem: 'hat check' problem. n people each check in a hat. Hats are randomly returned. Probability no one gets their own hat: !n/n! → 1/e ≈ 0.3679. Remarkably, for n ≥ 5, the probability approaches 1/e regardless of n — approximately 36.79% of random shuffles are complete derangements.

What should I know about Applications of Large Factorials?

Card shuffling: 52! different orderings of a deck. If you could check one trillion orderings per second since the Big Bang (13.8 billion years), you would have checked approximately 4.36×10²⁹ orderings — a tiny fraction of 52! ≈ 8×10⁶⁷. Every properly shuffled deck has almost certainly never existed before. Password spaces: an 8-character password from 62 characters: 62⁸ ≈ 2×10¹⁴. An 8-character ALL DIFFERENT character password: P(62,8) = 62!/(62-8)! ≈ 1.36×10¹⁴. Genetics: the number of possible orderings of genes along a chromosome, or the number of ways alleles can combine, both rely on factorial-based combinatorics to calculate.

What do I need to know about Stirling's Approximation?

Factorials grow so fast that exact calculation becomes impractical for large n — 100! has 158 digits. Stirling's approximation estimates factorials for large n: n! ≈ √(2πn) × (n/e)ⁿ. For n=10: exact 10!=3,628,800; Stirling gives √(62.8)×(3.679)¹⁰≈3,598,696 — within about 0.8% of the true value, and the approximation gets proportionally more accurate as n grows. This formula is essential in statistical mechanics (counting the number of ways particles can be arranged), information theory, and probability theory whenever a factorial of a very large number needs to be estimated without a computer handling arbitrary-precision arithmetic. It also explains why factorials appear in Taylor series convergence and in combinatorics formulas: taking the logarithm of Stirling's formula turns the product into a sum, making n! tractable in equations where only its order of magnitude, not its exact value, matters.

What should I know about Zero Factorial and Why 0! = 1?

By definition, 0! = 1 — not 0, which surprises many students. This isn't arbitrary: it preserves the recursive factorial rule n! = n × (n−1)! down to its base case, since 1! = 1 × 0! only works if 0! = 1. It also makes combination and permutation formulas behave correctly at their boundaries: C(n,0), the number of ways to choose nothing from n items, must equal exactly 1 (there's exactly one way to choose nothing), and C(n,0) = n!/(0!×n!) only gives 1 if 0! = 1. Similarly, the binomial theorem's first term, C(n,0)×aⁿ×b⁰, needs 0!=1 to correctly reduce to aⁿ. This convention is one of the cleanest examples in maths of a definition chosen specifically to keep a wider pattern of formulas consistent, rather than derived from counting objects directly.

What do I need to know about Factorials and Permutations with Repeated Items?

When arranging n items where some are identical to each other, straightforward n! overcounts arrangements that look the same because it treats identical items as distinguishable. The correction is to divide by the factorial of each repeated group's size: the number of distinct arrangements of a multiset is n! / (n₁! × n₂! × ... × nₖ!), where n₁, n₂, etc. are the counts of each repeated item. For the word "LETTER" (6 letters, with E repeated twice and T repeated twice), the number of distinct arrangements is 6!/(2!×2!) = 720/4 = 180, not 720. This formula is the direct bridge between factorials and the "permutations of a multiset" problems common in combinatorics coursework, and it explains why anagram-counting problems always ask you to first identify every repeated letter before dividing.

Factorial Values Reference Table

Factorials grow extremely fast — faster than exponential functions — which is why even modest values of n produce enormous results:

nn!
01
36
5120
75,040
9362,880
103,628,800
12479,001,600
151,307,674,368,000

Between n = 10 and n = 12, the factorial grows by a factor of over 132 (479,001,600 ÷ 3,628,800 ≈ 132), despite n only increasing by 2 — a vivid illustration of why factorial-based counting problems (like arranging a deck of cards, 52!) produce numbers with dozens of digits almost immediately.

Worked Example: Permutations and Combinations Using Factorials

A bookshelf has 9 different books, but there's only room to display 5 of them in a row. How many different ordered arrangements are possible, and how many different unordered selections of 5 books are possible? Ordered arrangements (permutations): P(9,5) = 9! / (9−5)! = 9! / 4! = 362,880 / 24 = 15,120 distinct ways to pick and arrange 5 books in order. Unordered selections (combinations): C(9,5) = 9! / (5! × 4!) = 362,880 / (120 × 24) = 362,880 / 2,880 = 126 distinct groups of 5 books, ignoring order. Notice that permutations are always larger than combinations for the same n and r — here by a factor of exactly 5! = 120 (15,120 / 126 = 120) — because each unordered group of 5 books can itself be arranged in 5! = 120 different orders. This is the core relationship behind the formula C(n,r) = P(n,r) / r!, and it's exactly what a factorial calculator is doing under the hood whenever you see "nPr" or "nCr" buttons on a scientific calculator.

Factorials in Probability: The Birthday Problem

A classic use of factorial-based counting is the "birthday problem": what's the probability that, among 5 randomly chosen people, at least two share the same birthday (ignoring leap years, 365 equally likely days)? It's easier to compute the probability that NO two people share a birthday, then subtract from 1. The number of ways to assign 5 different birthdays out of 365 days, in order, is the permutation P(365,5) = 365!/(365−5)! = 365 × 364 × 363 × 362 × 361. P(no shared birthday) = P(365,5) / 365⁵ = (365 × 364 × 363 × 362 × 361) / 365⁵ ≈ 0.9729. So P(at least one shared birthday) = 1 − 0.9729 = 0.0271, about 2.7%. This factorial-ratio method scales up dramatically: by the time you reach 23 people, the shared-birthday probability crosses 50%, and by 70 people it exceeds 99.9% — a famously counterintuitive result that surprises most people, since it feels like it should take closer to 183 people (half of 365) before a shared birthday becomes likely. The reason is combinatorial: the number of possible pairs of people grows much faster than the number of people themselves — with only 23 people there are already C(23,2) = 253 distinct pairs, each with its own small chance of a match, and those 253 independent opportunities add up surprisingly quickly even though any single pair is unlikely on its own. The same factorial-based permutation logic (P(n,r) = n!/(n-r)!) underlies password and PIN strength calculations, card-shuffling odds, and lottery number combinations — any situation where you're counting ordered arrangements drawn without replacement from a fixed pool. A standard 52-card deck, for instance, has 52! possible shuffle orderings — a number so astronomically large (over 8 × 10⁶⁷) that it vastly exceeds the number of atoms estimated to exist in the observable universe.

Factorial, Gamma Function & Stirling Calculator

Results update automatically as you type

Enter values above to calculate