THIS EXPLANATION
THE ROOM
MAT·18 Mathematics & Statistics 6 MIN · 8 STATIONS

Factorial explosion

A Socratic walk-through of factorial explosion — reasoned out one step at a time, not lectured.

abcdefgh
a

The question we started with

THE QUESTION #

Why is a shuffled deck of cards almost certainly in an order no deck has ever held before?

Shuffle a deck properly and the claim usually made is that the resulting order has never occurred before in the history of card playing. That sounds like the sort of thing people say for effect. Decks are small, fifty-two objects, and humans have been shuffling them for centuries. So is the claim rhetoric, or is there something about counting arrangements that we are systematically bad at estimating?

b

Reasoning it through

REASONING #

Count carefully rather than guess. To lay out n distinct objects in a row: n choices for the first position, n-1 for the second, n-2 for the third, and so on. Multiply them and you have n factorial, written n!. Nothing subtle has happened yet — it is just a product.

The subtlety is in how the product behaves. Ask yourself what happens when you add one more object to a set of n. Every arrangement you already had can now be extended in n+1 ways, so the count is multiplied by n+1. Not increased by a fixed amount, not doubled — multiplied by a factor that itself keeps growing.

Watch the numbers. 5! is 120, small enough to write out. 10! is 3,628,800 — already beyond hand enumeration. 20! is 2,432,902,008,176,640,000, about 2.43 billion billion. And 60! is roughly 8.3 x 10^81, which is larger than the commonly cited estimate for the number of atoms in the observable universe, around 10^80. Sixty objects. You could hold them.

Now the deck. 52! is about 8.07 x 10^67 — a sixty-eight digit number. Suppose, generously, that every one of ten billion people had shuffled a deck once per second since the universe began; that is under 10^28 shuffles. Against 10^67 possible orders, the fraction explored is so far below one that any given fair shuffle is, with overwhelming probability, unprecedented. The claim was not rhetoric.

Here is the distinction worth holding onto, because it is usually blurred. Exponential growth — 2^n, say — multiplies by a constant at each step. Factorial growth multiplies by a growing factor. At n = 20, 2^20 is about a million while 20! is about 2.4 million million million. Factorial eventually outruns any fixed exponential, and outruns it very quickly. When someone calls a factorial algorithm "exponential", they are being kind to it.

Why does this matter beyond card tricks? Consider the travelling salesman problem: visit n cities once each, return home, minimise total distance. Checking every tour means examining (n-1)!/2 of them. For twenty cities that is roughly 6 x 10^16 tours — and if you managed a billion tours per second, it would still take about two years. Twenty-five cities, and you are past the age of the universe.

So what should we conclude? Not that the problem is unsolvable, but that enumeration is not the route. Held and Karp's dynamic-programming method solves the same problem in time proportional to n^2 x 2^n, which is still exponential and still hopeless at scale — but it moves the wall from around twenty cities to around thirty, purely by refusing to look at each tour separately. Beyond that, practitioners use heuristics: nearest-neighbour construction, local improvement moves like 2-opt and Lin-Kernighan, branch-and-bound with good lower bounds. Modern solvers do prove optimality for surprisingly large instances — tens of thousands of cities — by pruning, not by counting.

Does that make heuristics a confession of laziness? Reverse the question: what would the alternative be? Against 10^67, no amount of hardware, patience, or funding closes the gap; doubling your computer buys you one more city. A method that gets within two percent of optimal in seconds is not a compromise on rigour. It is the only thing that is physically available.

c

The analogy

THE ANALOGY #
THE FIGURE

Think of a combination padlock where each turn of the dial adds a new digit — but the number of positions on the dial grows with every digit added. The first digit has three positions, the second has four, the third has five. Each extra digit does not just add options, it multiplies by a bigger number than the last one did, so a lock that looked trivial after four turns is unopenable after twenty.

WHERE IT BREAKS DOWN

A real padlock has a fixed number of dial positions, which is exactly the exponential case rather than the factorial one — and, more importantly, a lock has one correct answer, whereas the travelling salesman problem has a whole landscape of tours with a best one somewhere in it, which is what makes heuristic search possible at all.

d

Clarifying the model

THE MODEL #

Three refinements connect the steps above.

First, the deck argument depends on the shuffle actually being fair. Seven riffle shuffles is the well-known figure from Bayer and Diaconis for getting close to uniform; a casual two or three leaves substantial structure, and a fresh deck opened and cut a couple of times may well repeat an order that has occurred before. The mathematics of 52! is not in doubt — the assumption about the shuffle sometimes is.

Second, an enormous space does not by itself make a problem hard. Sorting n items also has n! possible orderings, and we sort millions of items routinely, because sorting has structure that lets us discard almost the entire space without looking at it. Difficulty comes from the absence of exploitable structure, not from the size of the count.

Third, "heuristics are necessary" is not the same as "optimality is unreachable". For the travelling salesman problem specifically, exact solvers have proved optimal tours for instances with tens of thousands of cities. What they never do is enumerate. The necessity is about the method, not about the standard of proof.

e

A picture of it

THE PICTURE #
Factorial explosion
Factorial explosion The horizontal axis is how many things you are arranging; the vertical axis counts digits, so every step up the scale is a tenfold jump in the actual number. Bars are n! and the line is 2^n, the standard exponential, drawn on the same scale for comparison. Notice the bars pull away from the line and never come back -- at n = 20 the exponential needs seven digits while the factorial needs nineteen. The rightmost bar, eighty-two digits for 60!, is the one that passes the atom count of the observable universe. {"generator":"[email protected]","source":"../Socrates/.diagram-cache/_src/factorial-explosion.md","sourceIndex":1,"sourceLine":4,"sourceHash":"f58e686930528cd36a8e9ab7108ef994b1023f9baf3f1145f76936f67884d627","diagramType":"xychart","layoutVariant":"source","repairedDuplicateIds":[],"motion":"entrance-with-reduced-motion-fallback","presentation":"editorial","attempt":1,"viewBox":{"x":0,"y":0,"width":790,"height":668},"qa":{"passed":true,"findings":[]}} 5 10 15 20 25 52 60 Number of items n 90 80 70 60 50 40 30 20 10 0 Digits in the result

How to readThe horizontal axis is how many things you are arranging; the vertical axis counts digits, so every step up the scale is a tenfold jump in the actual number. Bars are n! and the line is 2^n, the standard exponential, drawn on the same scale for comparison. Notice the bars pull away from the line and never come back — at n = 20 the exponential needs seven digits while the factorial needs nineteen. The rightmost bar, eighty-two digits for 60!, is the one that passes the atom count of the observable universe.

f

What became clearer

WHAT CLEARED #
WHAT CLEARED

Factorial growth is not exponential growth wearing a different hat — it multiplies by an ever-larger factor, so it overtakes any fixed exponential and does so early. That single fact explains both why a properly shuffled deck is very probably unique in history and why brute-force enumeration of tours, schedules, or orderings stops working at around twenty items regardless of hardware. Heuristics and pruning are not a lowering of standards; against a space of 10^67 they are the only method physics permits.

g

Where to go next

ONWARD #
  • Why some enormous search spaces (sorting, shortest paths) collapse under structure while others do not.
  • What "NP-hard" actually claims about the travelling salesman problem, and what it does not.
h

Key terms

TERMS #
TermWhat it means
Factorial (n!)the product n x (n-1) x … x 1, counting the orderings of n distinct objects.
Permutationone particular ordering of a set of objects.
Travelling salesman problemfind the shortest closed tour visiting each of n cities exactly once.
Heuristica method that finds a good solution quickly without guaranteeing it is the best one.
Held-Karp algorithman exact dynamic-programming solution to the travelling salesman problem running in time proportional to n^2 x 2^n.

Every term the collection defines is gathered in the glossary.

Nearby on the shelf

4