Birthday Problem Calculator
The chance that at least two people in a group share a birthday, the group size for a target chance, and the chance of a hash collision among n items.
Result…
How it's calculated
P(match) = 1 − N! ÷ ((N − n)! × Nⁿ) = 1 − Π (1 − i/N) for i = 0 … n − 1 Approximation: P ≈ 1 − e^(−n(n − 1) / 2N) Group for chance p: n ≈ √(2N ln(1/(1 − p)))
Answers the birthday problem exactly: the chance that at least two of n people share a birthday out of 365 equally likely days (or any number you choose), the smallest group that reaches a target chance, and the same question for hash collisions among n items in a space of N = 2^bits values. The exact product is computed in logarithms, so it stays accurate for 512-bit hashes and billions of items; the familiar exponential approximation is shown beside it.
Your numbers, step by step
About the Birthday Problem calculator
This birthday problem calculator works out the chance that at least two people in a group share a birthday, how big a group must be to reach a chance you choose, and the same question for computers: the chance that two of n items get the same hash value. The answer surprises most people, because a group of 23 already gives a better-than-even chance, and the reason is that every pair of people counts. Teachers use it to show how probability works, and developers use it to choose ID and hash lengths. The calculator works out the exact product rather than a rough rule, using logarithms so that even 512-bit hashes and billions of items cause no overflow. The familiar exponential approximation is shown beside it, and the working lists the pairs, the chance of no match and the final chance.
How to use it
- Under “Find”, choose “Chance of a shared birthday”, “Group size for a chance” or “Hash collision chance”.
- For birthdays, type the “People in the group”, or the “Target chance (%)” to find the group size. Use “Custom” under “Days in the year” for any number of equally likely values.
- For hashes, type the “Number of items n” and the “Hash length (bits)”, or switch “Hash size given as” to “Number of values N”.
- Read the chance, the approximation, the expected number of matching pairs and the size that gives a 50% chance.
Worked example
A class of 30 people has 30 × 29 ÷ 2 = 435 pairs. The chance that no one shares a birthday is 365/365 × 364/365 × … × 336/365 = 29.37%, so the chance of at least one shared birthday is 70.63%. For hashes: 1,000,000,000 items with a 64-bit hash have a 2.674% chance of at least one collision, and about 5,056,937,541 items give a 50% chance.
Updated
Questions people ask
How do I calculate the probability of a shared birthday?
Work out the chance that everyone differs, then subtract it from 1. With n people and 365 days, that chance is 365/365 × 364/365 × … × (365 − n + 1)/365. For 23 people it is about 49.27%, so a shared birthday has a 50.73% chance.
What is the formula for hash collision probability?
For n items in N equally likely values, the exact chance is 1 − N × (N − 1) × … × (N − n + 1) ÷ Nⁿ. When n is much smaller than N it is close to 1 − e^(−n(n − 1) ÷ 2N), and a 50% chance needs about 1.18 × √N items.
Why does such a small group give a 50% chance?
The question is about any two people, not someone matching you. 23 people make 253 pairs, and each pair has a 1 in 365 chance of a match, so the chances add up quickly. A common mistake is comparing 23 with 365 instead of counting the pairs.
Is the chance someone shares my birthday the same?
No. That is a different question: with n other people it is 1 − (364/365)ⁿ, so you need 253 others for a 50% chance. This calculator answers the any-pair question; for other set-ups, see the probability calculator.
How accurate is the result for real birthdays and real hashes?
It assumes every value is equally likely and independent. Real birthdays are slightly uneven, which makes a match a little more likely. A good hash spreads values evenly, but a weak or truncated hash can collide more often than this shows.