1. The question
How many people must be in a room for the chance that some two of them share a birthday to be above 50%? Most people guess around 180 (half of 365). The answer is 23.
Assume 365 equally likely birthdays (ignore 29 February) and people whose birthdays are independent — no twins.
2. Count the opposite event
"At least two share a birthday" can happen in very many ways. Its opposite — all birthdays different — is easy to count, person by person:
- the 1st person can have any day: ;
- the 2nd must avoid that day: ;
- the 3rd must avoid two days: ;
- … the -th must avoid days: .
The events are independent, so the probabilities multiply:
3. Plug in the numbers
- :
- :
- : — the first above one half
- :
- :
- :
4. Why so few? Count the pairs
A shared birthday needs only some pair of people to match — and the number of pairs grows much faster than the number of people:
Each pair matches with probability . Treating the pairs as roughly independent,
which reproduces the exact answer. The surprise comes from thinking about your own birthday instead of all pairs: the chance that one of 22 others shares your birthday is only , and you would need about 253 other people to push that to 50%.
5. Certainty
Only with 366 people is a shared birthday guaranteed: 366 people can't all fit into 365 days (the pigeonhole principle). Probability reaches 99.9% long before that, at 70.
The same maths is why computer scientists worry about "collisions" in hash functions: with possible values, a repeat becomes likely after only about tries.