Math & Geometry
Birthday Problem Calculator (Shared Birthday Probability)
Calculate the chance that two people in a group share a birthday. The birthday problem is one of the most famous surprises in probability. Most people guess that you would need well over a hundred people for a good chance of a shared birthday, yet in a group of just 23 people, the probability that at least two share a birthday is slightly more than 50%, and with 57 people it exceeds 99%. The result feels paradoxical because we instinctively think about the chance of someone matching our own birthday, which is indeed small, rather than the chance of any match among all the possible pairs. A group of 23 contains 253 different pairs, and each pair is a new opportunity for a match. The easiest way to calculate the probability is to work out the chance that everybody has a different birthday, multiplying 365/365 by 364/365 by 363/365 and so on, and subtracting the result from one. The same mathematics, known as the birthday attack in cryptography, explains why hash functions need long outputs to avoid collisions. Enter the number of people, the number of possible days and a target probability, and the calculator gives the probability of a shared birthday, the number of pairs, the chance someone shares your own birthday, the group size needed for your target and a table by group size.
How to use this calculator
- Enter the number of people in the group.
- Keep 365 days, or change it for other problems.
- Enter a target probability for the group size needed.
- Read the probability of a shared birthday.
- Compare group sizes in the table.
The birthday attack
In computing, a hash function maps data to a fixed number of possible values. The birthday problem shows that collisions appear after roughly the square root of the number of possible values, not after a number close to it.
That is why secure hash functions use outputs of 256 bits or more.
Trying it yourself
Classrooms of 25 to 30 pupils make good demonstrations: in most such groups, two people share a birthday.
Sports teams with squads of 23 players are often used as examples, and many squads do contain a shared birthday.
Formula & method
P(all different) = (365 ÷ 365) × (364 ÷ 365) × … × ((365 − n + 1) ÷ 365)P(at least one shared birthday) = 1 − P(all different)Assumes birthdays are equally likely and independent, ignoring 29 FebruaryP(someone shares your birthday) = 1 − (364 ÷ 365)ⁿ⁻¹P(all birthdays different) = ∏ from i = 0 to n − 1 of (d − i) ÷ d, with d = 365. P(at least one shared birthday) = 1 − P(all different). Number of pairs = n (n − 1) ÷ 2. P(at least one person shares a given person’s birthday) = 1 − ((d − 1) ÷ d)ⁿ⁻¹. The model assumes birthdays are independent and equally likely and ignores 29 February; real birth rates vary slightly by season, which raises the probability a little. With n > d, a shared value is certain.
Worked example
A group of 23 people
- P(all different) = 365/365 × 364/365 × … × 343/365 ≈ 0.4927.
- P(shared) = 1 − 0.4927 = 0.5073.
- Number of pairs = 23 × 22 ÷ 2 = 253.
Answer: A 50.7% chance that two people share a birthday.
Frequently asked questions
How many people are needed for a 50% chance?
23.
Why is it called a paradox?
Because the required group is much smaller than most people expect.
How many people for a 99% chance?
57.
What is the chance someone shares my birthday?
Much lower, about 5.9% in a group of 23.
Does it include leap years?
No, 29 February is ignored.
How is it calculated?
One minus the probability that all birthdays are different.