The Birthday Paradox: Why 23 People Is Enough

In a room of 23 people, it’s more likely than not that two share a birthday. Why it’s true, the maths in plain steps, and what it says about coincidences.

6 min readBy the Cognosc team

How many people do you need in a room before it’s more likely than not that two of them share a birthday? Most people guess somewhere between 100 and 183, because 183 is half of 365 and half sounds like a sensible threshold.

The answer is 23.

That’s true, it’s been checked by simulation and by counting real birthdays, and it feels wrong to almost everyone, including people who know probability. It’s called a paradox only because it feels like one. Nothing in the logic is contradictory. The surprise is the whole point.

Try it

How many people until two share a birthday?

Slide the number of people in the room, then fill a room and check.

50%100%23 people

With 23 people there are 253 different pairs, and a 50.7% chance that at least two share a birthday.

Ignores 29 February and assumes birthdays are spread evenly

Why it feels wrong

When people picture this, they usually picture themselves: what’s the chance someone shares my birthday? That really is small. In a room of 23, it’s only about 6%.

But the question isn’t about you. It’s about any two people in the room. And the number of pairs of people grows much faster than the number of people.

Think of a party. With 3 people there are 3 pairs. With 5 there are 10. With 10 there are 45. With 23 there are 253. Every one of those is a chance for a match, and chances add up quickly.

Count the pairs

In a room of 23 people, each person can be paired with 22 others. That’s 23 × 22 = 506, but that counts every pair twice (Ann and Bob, and Bob and Ann), so there are 253 different pairs.

Each pair has a 1 in 365 chance of sharing a birthday. With 253 chances at a 1 in 365 event, a match stops looking unlikely. A rough check: 253 ÷ 365 is about 0.69, so you’d expect around two thirds of a match, and the chance of at least one, once you allow for overlaps, comes out close to a half.

The exact calculation

It’s easiest to work out the chance that nobody shares a birthday, then take that away from 1.

  1. The first person can have any birthday.
  2. The second must avoid the first: 364 out of 365 days work.
  3. The third must avoid both: 363 out of 365.
  4. …and so on, down to the 23rd person: 343 out of 365.

Multiply those together: 364/365 × 363/365 × … × 343/365 comes to about 0.493. So the chance that nobody matches is 49.3%, and the chance that at least two people do is 50.7%.

This trick, working out the chance that something doesn’t happen and subtracting from 1, is one of the most useful in all of probability. “At least one” questions are usually hard to reach head-on and easy to reach from the other side. If you’ve ever wondered how to answer “what’s the chance I get at least one six in four rolls”, the same move works.

How fast it grows

The curve is much steeper than most people expect:

People in the roomPairsChance that two share a birthday
1045about 12%
23253about 51%
30435about 71%
501,225about 97%
571,596about 99%
702,415about 99.9%

By 57 people, you can bet almost any amount on a shared birthday. Only at 366 people is it certain, by the pigeonhole principle: you’d have run out of days.

A different question has a very different answer

Here’s the best way to feel the difference between “any pair” and “my birthday”. The same room, two questions:

Try it

Any pair, or someone with you?

Two different questions about the same room. How likely is it that some two people share a birthday, and how likely is it that someone shares yours?

With 23 people there are lots of pairs, so a match somewhere is 50% likely. But only 23 of those chances involve you, so a match with you is just 6%.

Uses a standard close approximation for the first figure; birthdays assumed equally likely, leap day ignored.

For the first, 23 people is enough. For the second, you’d need about 253, more than half the days in the year. The reason is that only the pairs that include you count. In a room of 23, that’s just 22 pairs out of 253. It’s easy to confuse the two questions because they sound alike.

Try it

Now a harder one

You’re in a room of strangers and want a better-than-even chance that at least one of them shares *your* birthday. About how many people do you need?

Pick one. You’ll see why straight after.

This is the commonest way to be wrong about the birthday problem: answering a question about you when the question is about anyone.

A real test: the presidents

You can check it on real data. Of the US presidents, two of them, James K. Polk and Warren G. Harding, were born on 2 November. With more than 40 people in the sample, the chance of at least one matching pair is above 90%, so it’s unremarkable.

The same holds for football matches: with 22 players on the pitch plus the referee, you have a room of 23, and in about half of all matches, two of them will share a birthday. Try it with a school class of 30 or a team of 40. It works better than most card tricks.

Variations that are just as surprising

Once you’ve counted pairs, you can ask nearby questions, and the answers are just as counter-intuitive.

  • Birthdays within a day of each other. If “near” means the same day or the next one, you only need 14 people for even odds, because each pair now has three ways to match.
  • Three people sharing a birthday. You need about 88 people for even odds of a triple, because triples are much rarer than pairs.
  • Two groups. If you have two separate groups, say two classes of 23, the chance that someone in one shares a birthday with someone in the other is also high, because the pairs run across the groups: 23 × 23 = 529 of them.
  • Other dates. The same arithmetic applies to anything with many possible values: phone numbers that end in the same four digits, cars with similar numberplates, people in a group who share a first name.

Try it on real data

It’s easy to test. Take any list with a few dozen dates in it: the members of a sports squad, the birthdays on a class register, the Wikipedia pages of people born in a given year. Count how many have a match. You’ll find the shared birthday much more often than you’d expect. After a few tries you stop being surprised, which is exactly what the maths predicts.

Where it matters beyond parties

Cryptography. Computers sometimes need to check whether two different inputs produce the same “hash”, a short fingerprint of data. Finding such a collision by brute force looks like it should take a number of tries equal to the number of possible fingerprints. The birthday effect says it takes only about the square root of that number. This is why a 128-bit hash gives only about 64 bits of protection against collisions, and why security designers use bigger ones than a naïve count suggests.

Databases and IDs. If you assign random IDs, clashes appear far sooner than the size of the ID space suggests. A system of 100,000 users with random 32-bit IDs has about a 70% chance of at least one clash.

Coincidences. This is the broader lesson. Statisticians Persi Diaconis and Frederick Mosteller called it the law of truly large numbers: with enough people and enough days, extremely improbable things are bound to happen to somebody. If a one-in-a-million coincidence can happen to any of a million people each day, it’ll happen to someone most days. It’s not a miracle. It’s the birthday problem at scale.

What to take from it

Our minds are good at noticing that something is surprising for me, and bad at counting how many chances there were for something surprising to happen to anyone. That’s why we’re astonished when we meet a stranger who shares our birthday, but not when we spot a coincidence among any two of the next hundred people we meet.

The practical test is to ask, of any coincidence, “how many chances were there?” A match between you and one other person is rare. A match somewhere among everyone is almost guaranteed. The more pairs there are, the less a coincidence should surprise you.

The probability test has the birthday question and a few others where counting the right things changes the answer.

Questions people ask

Why is the birthday paradox called a paradox?
It isn’t a logical paradox. It’s called one because the answer feels wrong: most people guess you’d need over a hundred people for even odds of a shared birthday. The real number is 23, which shows how badly our intuition handles pairs and combinations.
How many people do you need for a 99% chance of a shared birthday?
57. At 70 people the chance is about 99.9%, and at 100 people it’s better than 99.9999%. You only reach a guarantee at 366 people, by which point every day of the year, including 29 February, must have been used.
Does the birthday paradox assume all birthdays are equally likely?
The standard calculation does, and it ignores 29 February. Real birthdays aren’t quite uniform, with more births in some months than others, and that makes a shared birthday slightly more likely than the textbook figure, not less.
What is the birthday attack in cryptography?
Finding two different inputs that produce the same hash value. Because of the birthday effect, you only need to try about the square root of the number of possible hashes to find a collision, so a 128-bit hash can be broken in roughly 2 to the 64 tries instead of 2 to the 128.
How many people do you need for a shared birthday with you specifically?
About 253 for better-than-even odds. That’s very different from 23, because the question is no longer about any pair: only the pairs that include you count, and there are just as many of those as there are other people.

Sources and further reading

  • von Mises, R. (1939). Über Aufteilungs- und Besetzungswahrscheinlichkeiten. Revue de la Faculté des Sciences de l’Université d’Istanbul, 4, 145–163.
  • Diaconis, P. and Mosteller, F. (1989). Methods for studying coincidences. Journal of the American Statistical Association, 84(408), 853–861.
  • Feller, W. (1968). An Introduction to Probability Theory and Its Applications, Vol. 1 (3rd ed.). Wiley.
  • Ball, W. W. R. and Coxeter, H. S. M. (1987). Mathematical Recreations and Essays (13th ed.). Dover.
Go deeper

Learn how to count coincidences

Cognosc turns this into a goal on this topic: it finds what you already know, starts from there, and keeps checking you still understand it.

Your goalProbability of coincidences: the birthday paradox, counting pairs, and the complement rule