The Infinite Monkey Theorem

If a monkey presses keys at random on a keyboard for an infinite amount of time, it will eventually type any given text, including the complete works of Shakespeare.

How does it work?

The theorem is based on probability. Each time the monkey presses a key, there is a small but non-zero probability that it is the correct character. With an infinite number of attempts, any finite sequence of characters will appear with probability 1.

In mathematics this is known as the Borel-Cantelli lemma: if an event has a positive probability of occurring on each attempt, it will occur infinitely many times given an infinite number of attempts.

An example to put it in perspective

The probability of a monkey typing the word "SHAKESPEARE" (11 letters) by pressing random keys from 28 characters (26 letters, space and newline) is:

(1/28)¹¹ ≈ 1 in 17,537,720,524,288,000

Nearly impossible in one attempt, but inevitable with infinite attempts.

Try being the monkey →Watch the bot monkey →