← Math problems

The birthday paradox 23 people. Better than even odds of a match.

How many people do you need in a room before two of them probably share a birthday? Most people guess around 180. The answer is 23. With 70 people a match is almost certain. Check it with a game, a simulation and five explanations.

23people → 50.7%
70people → 99.9%
The puzzle

Picture this: a class of 30 students

The birthday problem, or birthday paradox, is usually credited to the mathematician Richard von Mises in 1939. It isn't a real contradiction. It's called a paradox because the right answer sounds impossible.

  1. 1

    The room

    There are n people in a room: a class, a team, wedding guests. Nobody arranged their birthdays.

  2. 2

    The calendar

    A year has 365 days. We assume each person is equally likely to be born on any of them. We ignore 29 February.

  3. 3

    A match

    A match means at least two people share a day and month. The year doesn't matter, and neither does who: any pair counts.

  4. 4

    The question

    What is the smallest n for which the chance of a match exceeds 50%? And what are the odds in a class of 30?

Intuition says

"There are 365 days, so you need about half that, around 183 people"

In fact 23 is enough. In a class of 30 there is a match 70% of the time. The mistake is thinking about your own birthday, when what counts is every pair of people.

Model assumptions

  • 365 days, no 29 February.
  • Every day is equally likely.
  • Birthdays are independent: no twins.

Real birth rates are uneven, which only raises the chance of a match. More in round 4.

Round 1 · Guess

How many people for a 50% chance?

Lock in your answer before reading on. It shows how far intuition misses.

183
2100200300366

Your answer will be compared with the right one here.

Round 2 · Fill a room

Invite people until two share a birthday

Each new person gets a random birthday and takes a calendar cell. When two land on the same day, the cell lights up. Fill 10 to 15 rooms: the panel on the right shows when the first match usually happens.

People in the room0
Matches0
Theoretical chance of a match0%

When the first match happened

1204060+

Theory: median 23, mean ≈ 24.6. The orange bar contains the median of your rooms.

Round 3 · Simulation

10,000 rooms in a second

The computer builds thousands of rooms of n people and counts how many have a match. The line is the exact formula; the dots are the simulation.

exact formula simulation
–
Exact formula
–
Round 4 · Five explanations

Why so few people

The key is that a match can happen in any pair, and there are far more pairs than people. Here are five ways to see it.

Count the pairs

23 people make 253 pairs

Through the opposite event

Compute the chance of no match

The first person can be born any day. The second must miss that day: 364/365. The third must miss two days: 363/365. Each factor is close to 1, but there are many of them. After the 23rd person the product drops below 50%.

You versus everyone

Why intuition lies

One of the 22 others shares your birthday5,9%needs 253 people for 50%
Any two of the 23 share a birthday50,7%23 people are enough for 50%

When we picture the problem, we put ourselves in it: "who else was born on 14 March?" That is a different, much rarer event. Your day is tested in only 22 pairs, out of 253 pairs in total.

The real world

Uneven birthdays only help

Real birth rates vary: some months see more births, holidays fewer. Any unevenness raises the chance of a match, because people crowd into the "popular" days. A uniform calendar is the worst case, so 23 is an upper bound.

With 366 people a match is 100% certain (ignoring 29 February). That's the pigeonhole principle: with more pigeons than holes, two must share.

For formula lovers

The exact formula and a handy approximation

P(no match) = 365/365 · 364/365 · 363/365 · … · (365−n+1)/365
P(match) = 1 − 365! / ((365−n)! · 365n)
P(match) ≈ 1 − e−n(n−1)/(2·365)  →  n = 23: 1 − e−253/365 = 0,500
n50% ≈ 1,1774 · √D  →  D = 365: 1,1774 · 19,1 = 22,5

The approximation says it all: the exponent is the number of pairs divided by the number of days. So the number of people needed grows like the square root of the number of days. For 365 days that's about 23, not 183.

Round 5 · Scaling up

Other calendars, triples and neighbouring days

The same idea works for any kind of "day": months, PIN codes, hashes. And the problem can be made harder: look for three people on one day, or people born a day apart.

People needed for a 50% chance of a match

Possible values
People needed (exact)
≈ 1,1774 · √D

A square root, not a half

Both axes are logarithmic. Intuition expects the line "half of D"; the truth is ≈ √D. For a million values that's 1,178 instead of 500,000.

Harder variants

Press "Check": 10,000 simulated rooms show that at the given size the chance really is about 50%.

What we look forPeople for 50%
Bonus · Fun facts

Things to tell your friends

16 / 32

The 2014 World Cup

Every squad at the 2014 football World Cup had exactly 23 players. The BBC checked their birthdays: 16 of the 32 teams had a shared birthday, exactly half, just as the formula predicts.

2 November

US presidents

James Polk and Warren Harding were both born on 2 November. And three of the first five presidents, John Adams, Thomas Jefferson and James Monroe, died on 4 July, Independence Day.

1 / 1461

29 February

The chance of being born on 29 February is about 1 in 1,461. We left the day out of the model, and adding it back changes nothing: 23 people still give a chance just over 50%.

September

Birthdays aren't uniform

In many countries the most births happen in late summer and September, and the fewest on holidays such as 25 December and 1 January, since planned deliveries rarely land on them. This unevenness only raises the chance of a match.

2⁶⁴

Why hashes are so long

Finding a collision in a 64-bit hash takes not 2⁶⁴ tries but about 2³², roughly 5 billion. A modern computer does that in minutes. That's why cryptography uses 256-bit hashes: even 2¹²⁸ tries are out of reach.

253

More pairs than you think

A class of 30 has 435 pairs; a wedding with 100 guests has 4,950. The chance that such a wedding has no shared birthday at all is about 1 in 3,300,000.

Discussion

What do you think?

Share your own explanation, an objection or a variant of the puzzle. Commenting needs a GitHub account.

Newsletter

New puzzles, explanations and discussions

I keep adding new puzzles, new ways to explain them and write-ups of the discussions they start. Leave your email and I'll write when something new is out. No spam, one-click unsubscribe.

The sign-up form will appear here soon.