← Back to Paradoxes

🐒 The Infinite Monkey Theorem

Given infinite time, random typing will produce Shakespeare... but how long would that really take?

The Thought Experiment

A monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type any given text, including the complete works of William Shakespeare.

The theorem is mathematically true—but the practical reality is staggering. Even typing a simple word like "banana" would take longer than the age of the universe!

Watch a Monkey Type Random Characters

Can it match the target text by pure chance?

🐒
Target: "to"
0
Attempts
0
Total Keystrokes
0
Best Match
0
Successes

📊 Probability of Random Success

With 27 keys (a-z + space), the probability of typing each phrase by chance:

"to" (2 characters) 1 in 729 (0.14%)
"banana" (6 characters) 1 in 387,420,489
"hamlet" (6 characters) 1 in 387,420,489
"to be or not to be" (18 chars) 1 in 10^25 (approximately)
Complete works of Shakespeare (884,647 words) 1 in 10^millions

⚡ The Paradox

Mathematically: Given infinite time, the probability of typing any finite text approaches 1 (certainty). This is what "almost surely" means in probability theory.

Practically: A 2024 study calculated that even with 200,000 chimpanzees typing one key per second until the heat death of the universe (10100 years), there's only a 5% chance of typing just the word "bananas"!

The paradox: Something can be mathematically certain yet physically impossible. Infinity is not just a big number—it's a different concept entirely.

The Mathematics

P(text) = (1/n)k

Where n = number of keys, k = length of text

🔢
Example - "banana": With 27 keys (a-z + space), P = (1/27)6 = 1/387,420,489 ≈ 0.00000026%
⏱️
Expected attempts: On average, you'd need 387 million attempts to type "banana" once. At 1 keystroke/second, that's 12 years of continuous typing!
Infinite limit: As attempts → ∞, probability of eventual success → 1. But "eventually" might mean 101000000 years!
13.8 billion years
Age of the universe
10100 years
Time until heat death of universe
10360,783 years
Expected time to type "Hamlet"
5%
Chance of typing "bananas" before heat death

What Does "Almost Surely" Mean?

In probability theory, almost surely (abbreviated "a.s.") means an event occurs with probability 1, but there exist outcomes where it doesn't happen.

Example: If you throw a dart at a dartboard, the probability of hitting any specific mathematical point is exactly 0. Yet the dart will hit somewhere. Every specific outcome has probability 0, but some outcome is certain.

Similarly, the probability that a random infinite sequence of letters never contains Shakespeare is 0. But this doesn't mean every infinite sequence contains it—it means the "bad" sequences form a set of measure zero.

A Brief History

1913
French mathematician Émile Borel first describes the theorem in Mécanique Statistique et Irréversibilité, imagining monkeys typing all books in the Bibliothèque nationale de France.
1928
Arthur Eddington popularizes the image, using it to illustrate the Second Law of Thermodynamics and entropy.
1979
Douglas Adams references it in The Hitchhiker's Guide to the Galaxy with an infinite number of monkeys producing Hamlet.
2003
The "Paignton Zoo experiment" placed a keyboard in a monkey enclosure. After a month, the macaques produced 5 pages mostly of the letter 'S', with no words.
2024
University of Technology Sydney publishes study showing even "bananas" is unlikely before the heat death of the universe with realistic parameters.
"If I let my fingers wander idly over the keys of a typewriter it might happen that my screed made an intelligible sentence. If an army of monkeys were strumming on typewriters they might write all the books in the British Museum."
— Arthur Eddington, The Nature of the Physical World (1928)

Why This Matters

The Infinite Monkey Theorem illuminates the gulf between mathematical infinity and physical reality. It shows that:

It's also a beautiful reminder that Shakespeare wasn't random—his works emerged from creativity, learning, culture, and intention. Random processes, no matter how long, cannot replicate the meaning behind language.