Mathematics
Why do two people in 23 probably share a birthday?
Put 23 people in a room. The chance that at least two of them share a birthday is just over a half. Many people guess something far lower, nearer 6%. The gap between the guess and the truth is about what we choose to count.
Here is the usual line of thought. A year has 365 days. Twenty-three people can cover at most 23 of those days, about 6% of the year, so a shared birthday ought to be rare. When someone asks “does anyone here share a birthday?”, we quietly hear “does anyone share my birthday?” — and that really is unlikely in a room of 23.
But the question doesn’t care whose birthday it is. Any two people will do. Before we count anything, let’s just try it.
Fill a room
In the figure below, each dot is one person, placed on a ring of the 365 days of the year, January at the top and running clockwise. Every birthday is drawn at random, with each day equally likely. When two people land on the same day, their dots stack up and turn red, and the first shared day is labelled.
- People
- 23
- Pairs of people
- 253
- First match
- —
- Days shared
- Rooms with a match (simulated)
- —
- Exact chance
- 50.7%
If you pressed Add until a match a few times, you probably saw rooms of 15, 25, 30 — sometimes fewer than 10. Across many tries, half of all rooms have their first match by the 23rd person. And when you run 1,000 rooms of 23, about 507 of them have a match. The number after the ± is the honest size of the sampling error: a thousand random rooms can easily land three points either side of the true value.
Count pairs, not people
The reason is that a match needs two people, so what matters is how many pairs of people there are. Each person can pair with everyone else, and every pair gets counted twice that way, so a room of n people holds
n(n − 1) / 2 pairs.
That grows roughly like the square of n. Twenty-three people make 253 pairs. Each pair has only a 1-in-365 chance of matching, but 253 chances at 1 in 365 add up.
Now compare the question we usually hear. Of those 253 pairs, only 22 include you. The chance that one of the other 22 people shares your birthday is 1 − (364/365)22, about 5.9%. That is the number our intuition tends to reach for.
- Pairs
- 253
- Pairs that include you
- 22
- Any two share a birthday
- 50.7%
- Someone shares yours
- 5.9%
The pair count is a good guide but not the exact answer, because pairs are not independent: if Ann matches Ben and Ben matches Cat, then Ann matches Cat. The exact calculation is easier from the other side. Ask for the chance that nobody shares. The first person can have any birthday. The second must avoid one day: 364 out of 365. The third must avoid two: 363 out of 365. Keep going and multiply:
P(no match) = 365/365 × 364/365 × 363/365 × … × (365 − n + 1)/365
For 23 people this product is 0.4927, so the chance of at least one shared birthday is 1 − 0.4927 = 0.5073, or 50.7%. With 57 people it is 99.0%, and with 70 people 99.9%. To reach even odds of someone sharing your birthday you need 253 other people — as many people as there are pairs in a room of 23.
Any number of days
Nothing here is special to birthdays. Replace the 365 days with any number d of equally likely values — lottery numbers, seat numbers, the outputs of a computer program — and draw at random. A repeat becomes likely once the number of pairs, about n2/2, is comparable to d. Working that out exactly gives a simple rule: the chance of a repeat reaches 50% after about
n ≈ 1.1774 × √d draws,
where 1.1774 is √(2 ln 2). For 365 days the rule gives 22.5, and the exact answer is 23. For a million values it gives 1,177; the exact count is 1,178. Square roots shrink big numbers dramatically: a million values only need about a thousand draws.
- Size in bits, log₂ d
- 8.5 bits
- Draws for a 50% chance of a repeat
- 23
- 1.1774 × √d
- 22
- Draws as a share of d
- 6.3%
This is why cryptographers care about birthdays. A hash function turns any file into a short fixed-length fingerprint, say 128 bits, so there are d = 2128 ≈ 3.4 × 1038 possible fingerprints. Finding a file that matches one particular fingerprint by trial is like waiting for someone with your birthday: about 2128 tries. But finding any two files with the same fingerprint, a collision, is the birthday problem: about 1.18 × 264 ≈ 2 × 1019 tries. That is why a hash with b bits offers only about b/2 bits of protection against collisions, and why modern standards such as SHA-256 use outputs twice as long as the security level they aim for. The attack is called a birthday attack.
Real birthdays are not uniform
Everything so far assumed every day is equally likely. Real birthdays aren’t. In the United States from 1994 to 2003 — 39.7 million births, counted by the National Center for Health Statistics — late summer and September were busiest, and holidays were quiet, because many deliveries are scheduled. The busiest date, 19 September, had 11% more births than an average day; 25 December had 37% fewer.
Does that help or hurt the chance of a match? It helps. When some days are more popular, people crowd onto them, and crowding is exactly what makes matches. Mathematically, equal chances for every day give the fewest matches of any pattern.
- Shared birthday, all days equal
- 50.73%
- With these rates
- 50.83%
- Difference
- +0.10 percentage points
- Smallest room for 50%
- 23 people
At real rates the chance for 23 people rises by only a tenth of a percentage point, from 50.73% to 50.83%, and 23 is still the smallest room that passes a half. The uniform model is a very good approximation — and where it is wrong, it errs on the side of underestimating matches.
What this model leaves out
- Birth rates in other places and years. Figure 4 uses one country and one decade. Seasonal patterns differ between countries and have changed over time, but the effect on the birthday problem stays small unless the pattern is far stronger.
- 29 February. We use 365 days. Adding a leap day a quarter as likely as the others lowers the chance for 23 people from 50.73% to 50.69%.
- Twins and families. The model assumes birthdays are independent. A room with twins, or a class of children born in the same school year, breaks that.
- Real hash attacks. The √d count is the number of fingerprints to compute. A naive attack must also store and search them all; practical methods (Pollard’s rho, parallel collision search) trade memory for extra computation. Some real hash functions, such as MD5 and SHA-1, have been broken much faster than the birthday bound by exploiting their internal structure. The birthday bound is what a perfect hash can promise, not a guarantee about any particular one.
Sources
- W. Feller, An Introduction to Probability Theory and Its Applications, vol. 1, 3rd ed. (Wiley, 1968), ch. II §3, example “Birthdays”. The classical calculation of the chance that r people all have different birthdays, and its approximation through logarithms.
- A. J. Menezes, P. C. van Oorschot and S. A. Vanstone, Handbook of Applied Cryptography (CRC Press, 1996), §2.1.5 “Birthday problems”; free chapter at cacr.uwaterloo.ca. The general form P = 1 − m(m−1)…(m−n+1)/mn for drawing n of m values, with P(365, 23) ≈ 0.507 and P(365, 30) ≈ 0.706; the occupancy-problem view of the same question.
- J. Katz and Y. Lindell, Introduction to Modern Cryptography, 3rd ed. (CRC Press, 2021), §6.4.1 “Birthday attacks for finding collisions”, §6.4.2 “Small-space birthday attacks”, and Appendix A.4 on the birthday problem. A collision in an ℓ-bit hash is found with about 2ℓ/2 evaluations, so collision-resistant hashes need outputs twice the security level; small-space birthday attacks.
- FiveThirtyEight, “births” data set, from the CDC’s National Center for Health Statistics, US births by day, 1994–2003; github.com/fivethirtyeight/data. Daily US birth counts, 1994–2003 (39.7 million births), summed by calendar date for Figure 4.
Colophon
- Date
- 1 October 2026
All probabilities on this page are computed in your browser; the exact values were checked against an independent calculation in exact fractions. Nothing is loaded from the network.