How many people must be in a room before two of them are more likely than not to share a birthday? Most people guess around 180, half of 365. The real answer is 23. This surprising result is the birthday paradox; it is not a contradiction, just a reminder that our intuition counts the wrong thing. With 23 people there are 253 different pairs, and every pair is a chance for a match.
This calculator gives the exact probability that at least two of people share a birthday, using the product formula rather than a rough estimate. You can also change the number of possible days — 12 for birth months, 7 for weekdays, any number of equally likely values — or turn the question around and ask how many people are needed to reach a target probability such as 50 %, 90 % or 99 %.
The same mathematics governs hash collisions in computing. A hash function maps data to one of values; the birthday bound says that collisions become likely after only about items, not . The hash mode computes this risk for any size from 1 to 256 bits, which is why 32-bit checksums are unsafe as unique identifiers and why cryptographic hashes need at least twice as many bits as the security level they aim for.
How to use this calculator
- Choose Probability to get the chance of a match for a given group, People needed to find the group size for a target probability, or Hash collisions for computing problems.
- Enter the number of people (or items) and the number of possible days (or values). Keep 365 for ordinary birthdays.
- For hash collisions, enter the hash size in bits and how many items you will hash.
- Read the probability at the top, then the chance that everyone is different, the quick approximation, the expected number of matching pairs and the group size needed for a 50 % chance. The chart shows how fast the probability climbs as the group grows.
The formula
With equally likely days and people, the probability that everyone has a different birthday is
and the probability of at least one shared birthday is . Since for small :
The expected number of pairs sharing a day is . For a hash of bits, . If , a match is certain by the pigeonhole principle. The model assumes all days are equally likely; real birth dates are slightly uneven, which only makes matches a little more likely.
Worked example
The classic case. With 23 people and 365 days, the probability that at least two share a birthday is 50.7% (0.5073). Among them are 253 pairs, and the expected number of matching pairs is 0.693.
Bigger groups. With 50 people the probability reaches 97%; with 70 people it is 99.92%. You need 23 people for a 50 % chance and only 57 for 99 %.
Birth months. In a group of 5, the chance that two were born in the same month (12 values) is 61.8%.
Hash collisions. Hashing 100,000 items with a 32-bit hash gives a collision probability of 68.8%. A 50 % chance is reached after only 77,164 items, out of more than 4 billion possible values.
Why the result feels wrong
The intuitive guess answers a different question: how many people are needed for someone to share your birthday. That probability is and reaches 50 % only at 254 people. The birthday paradox asks about any pair, and the number of pairs grows with the square of the group size. Ten people form 45 pairs; 23 people, 253; 70 people, 2,415. This quadratic growth is what cryptographers call the birthday attack: finding any two inputs with the same hash takes about attempts, far fewer than the needed to match one given hash.
Frequently asked questions
Why is the answer 23 people?
Because 23 is the smallest group for which the product (365/365)(364/365)…(343/365), the chance that all birthdays differ, falls below one half. With 22 people the match probability is 47.6 %; with 23 it is 50.7 %.
What about February 29 and uneven birth dates?
Leap-day births are rare enough to change the result very little. Real birthdays are not perfectly uniform (some months have more births), and any unevenness makes shared birthdays slightly more likely, so 365 equal days is a conservative model.
How does the birthday paradox apply to hash collisions?
A b-bit hash has 2^b possible outputs, which play the role of days. The chance of two different items getting the same hash becomes 50 % after about 1.18 × 2^(b/2) items. For a 64-bit hash that is roughly 5 billion items, for a 128-bit hash about 2 × 10¹⁹.
How accurate is the approximation 1 − e^(−n²/2d)?
Very accurate when n is small compared with d, which is the usual situation for hashes. For birthdays it is off by less than one percentage point for groups up to about 60. The calculator always shows the exact product next to it.
What is the chance that someone shares my birthday?
That is a different question: with n other people it is 1 − (364/365)^n. You need 253 other people for a 50 % chance, which is why the classic paradox surprises so many people.
Sources
- W. Feller, An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd ed. (Wiley), §II.3 — the birthday example
- P. Diaconis & F. Mosteller, Methods for Studying Coincidences, Journal of the American Statistical Association 84 (1989) 853–861
Last updated: