Could a monkey banging on a typewriter ever produce Hamlet? Mathematically, yes, if it types forever. The infinite monkey theorem says that a random typist given infinite time will almost surely produce any given text. It is a vivid way to show how strange infinity is, and how enormous "very unlikely" can be.

The idea in plain terms
Imagine a keyboard with about 30 keys and a monkey that presses one at random every second. The chance of typing the word "banana" in six key presses is (1/30)⁶, about 1 in 729 million. That is tiny but not zero. If the monkey keeps going without end, every attempt is another independent chance, so the probability of never typing "banana" shrinks toward zero.
The same logic applies to any finite text, even all of Shakespeare. With infinite time, the probability of eventually producing it is 1, which mathematicians describe as "almost surely."
Key idea
The theorem is about infinity, not about real monkeys. With any realistic amount of time, the chance of typing even one page of Shakespeare by pure chance is effectively zero.
Origin
The French mathematician Émile Borel used the image of monkeys at typewriters in a 1913 essay about statistical mechanics, to describe events that are possible but so improbable they never happen in practice. The idea was later popularized in English by writers and scientists, including Arthur Eddington, and it appears in pop culture from novels to TV comedies.

How big the numbers are
Shakespeare's complete works contain several million characters. The odds against typing them randomly in one attempt are so vast that even if every atom in the observable universe were a monkey typing since the Big Bang, the expected time to succeed would still be far, far longer than the age of the universe. That is why the theorem is often used to separate "possible in principle" from "possible in practice."
US cases
- When and where
- August–October 2011, Reno, Nevada
- What happened
- Programmer Jesse Anderson used software "monkeys" running on Amazon's cloud and later his home computer to generate random nine-letter strings. Each string was checked against Shakespeare's texts from Project Gutenberg, and matching pieces were kept. On October 6, 2011, he announced that every work had been covered. The BBC and other outlets reported the result.
- Why it matters
- Anderson himself explained that keeping matches as you go is what made it possible, which shows the gap between pure randomness and random variation plus selection.
Common misunderstandings
- It does not prove randomness can create meaning quickly. The theorem says nothing about realistic time frames.
- It is not an argument for or against evolution. Biologists point out that evolution includes selection, which, as Anderson's project shows, changes the odds dramatically.
- "Almost surely" is not "surely." In infinite probability spaces, an event with probability 1 can still, in principle, fail to occur.
Related concepts
The theorem relates to the law of large numbers and to ideas about randomness in finance such as the random walk hypothesis. People who expect random events to "balance out" commit the gambler's fallacy. Like Zeno's paradoxes, it shows how infinity defies intuition.
Frequently asked questions
- Is the infinite monkey theorem true?
- Yes, as a mathematical statement about infinite time; it does not mean a real monkey could type Shakespeare.
- Who came up with the infinite monkey theorem?
- The French mathematician Émile Borel used the image in 1913.
- Did anyone actually test it?
- A 2011 computer project by Jesse Anderson used virtual monkeys, but it kept matching fragments as it went, so it was not pure random typing.