23
1,000
20

More information about the birthday paradox

The birthday paradox

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 only 23: then the chance is 50.7%, and with 57 people it is already 99%. It feels wrong because we think of our own birthday, while the paradox is about every pair in the room. In a group of only 23 people, the chance that two of them share a birthday is 50.7%. That sounds far too high, because we think of our own birthday: the chance that someone shares yours is only 6%. But 23 people make 253 pairs, and each pair could share a birthday. Click for a new group and watch the pairs pile up, add people one by one, or test 1,000 groups and every group size to see the curve rise.

How it works

  1. Click the stage for a new group of 23 people. They join one by one, and a line appears for every new pair.
  2. Watch the calendar: a day with two birthdays lights up, and the message names the shared birthday.
  3. Press Test automatically for 1,000 groups, or Test every group size to see the chance rise from 2 to 100 people.

Why our intuition fails

In a room we unconsciously reason from ourselves: what is the chance that someone shares my birthday? With 365 days that chance is small, about 6% with 22 others. But the paradox asks whether any two people share a birthday: A and B, B and C, A and C, and so on. Twenty-three people make 23 × 22 / 2 = 253 pairs, and every one of them is a chance for a match. The number of pairs grows with the square of the group, so the chance shoots up.

The calculation

It is easiest to work out the chance that nobody shares a birthday, and subtract it from 100%. The first person takes any day. The second has a chance of 364/365 of a different day, the third a chance of 363/365 of avoiding the first two, and so on. For 23 people: 365/365 × 364/365 × 363/365 × … × 343/365 ≈ 49.3%. The chance of at least one shared birthday is then 100% − 49.3% = 50.7%.

Someone with your birthday

The chance that someone in the group shares your own birthday grows much more slowly: 1 − (364/365)ⁿ⁻¹, because only n − 1 of the pairs include you. With 23 people it is 5.9%, and you need 253 others to pass 50%. Switch the question to Someone shares your birthday to compare both curves.

Birthday attacks in cryptography

The paradox is more than a party trick. In computer security it is the basis of the birthday attack: to find two inputs with the same hash, a collision, an attacker needs far fewer tries than you would expect. For a hash with N possible values, a collision becomes likely after roughly √N tries rather than N. That is why hashes and digital signatures need outputs long enough that even √N tries are out of reach: for a 128-bit hash a collision takes about 2⁶⁴ tries.

Frequently asked questions

How many people do you need for a 50% chance of a shared birthday?

23. Then the chance is 50.7%. With 30 people it is 70.6%, with 41 people 90.3%, with 57 people 99.0%, and with 70 people 99.9%.

Why is it called a paradox?

It is not a contradiction, only a surprise: the answer goes against intuition. Most people guess that you need about half of 365, around 180 people, because they compare everybody with themselves instead of with each other.

What about 29 February and real birth dates?

The app, like the classic problem, takes 365 equally likely days. Real birthdays are not spread quite evenly over the year, and an uneven spread makes a shared birthday slightly more likely, not less.

When is a shared birthday certain?

With 366 people: there are only 365 days, so by the pigeonhole principle at least two of 366 people must share one. Long before that it is practically certain: with 100 people the chance is 99.99997%.

Does this upload anything?

No. Everything is calculated and drawn on a canvas in your browser. Save downloads a PNG. Edit opens that image in the PictorX editor.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Go to Editor