Puzzles have a way of making me stop and ask: why does that work?
I enjoy finding the answer, but I’m usually more interested in pulling it apart—getting past what seems obvious and finding the simple ideas underneath. That curiosity is why I started jmnio math.
The birthday paradox felt like a fitting first reel: a puzzle about birthdays to mark the birth of the channel.
A room, a question, and a surprising answer
How many people do you need in a room before the chance that at least two share a birthday exceeds 50%?
If your first guess is somewhere near half of 365, you’re in good company. My intuition wanted a much larger room, too.
The answer is 23 people. Under the usual assumptions, the probability is about 50.73%.
This isn’t a logical contradiction. It’s called a paradox because the result clashes with what many of us expect. To understand it, we need to ask exactly what is being compared.
First, agree on the model
We’ll assume 365 equally likely birthdays, ignore leap days, and treat different people’s birthdays as independent. We compare the day and month, not the year.
Real birthdays are not perfectly uniform, and related people may have dependent birthdays. This is a simplified model that lets us see the mechanism clearly.
Crucially, the question is whether any pair shares a birthday. It is not whether someone shares your birthday.
Count the opposite
Calculating every possible way a match could occur gets messy. There could be one matching pair, several pairs, or three people sharing a birthday.
Instead, count the one situation with no matches: everyone has a different birthday. Then subtract its probability from 1. These two possibilities cover every outcome.
Imagine people entering the room one at a time:
- Person 1: any birthday is fine. The probability is 365/365 = 1.
- Person 2: must avoid the first birthday. There are 364 acceptable days, giving 364/365.
- Person 3: provided the first two birthdays differ, must avoid both. That gives 363/365.
- Person n: provided all previous birthdays differ, must avoid n − 1 occupied days. That leaves 365 − n + 1 acceptable birthdays.
We multiply these conditional probabilities, using the chain rule:
For whole-number group sizes from 1 to 365, factorial notation makes this shorter:
So the answer to our original question is:
Substitute n = 23 and we get approximately 0.5073, or 50.73%. With 22 people it’s about 47.57%, so 23 is the first group size to cross 50%.
With 366 people, a match is guaranteed under this 365-day model: there are more people than available birthdays.
The hidden multiplier: everyone can match everyone
Our intuition often imagines one person comparing their birthday with everyone else. With 23 people, that would mean just 22 comparisons.
But our question allows any two people to match. The number of distinct pairs is:
For 23 people, that’s 253 pairs.
Each new person creates a possible match with every person already in the room. The 23rd person adds 22 new pairs, not just one.
These pair comparisons are not all mutually independent, and several can match at once. So we cannot simply divide 253 by 365 to get the probability of at least one match. That ratio is the expected number of matching pairs, a different quantity.
The exact calculation above handles overlaps correctly. Counting pairs explains why the surprise happens.
A deeper look: why pairs appear in the approximation
The product for no matches can also be written as:
For small x, the first-order approximation ln(1 − x) ≈ −x is useful. Taking natural logarithms turns the product into a sum:
Exponentiating and taking the complement gives:
There are the pairs again. At n = 23, this approximation gives about 50.00%, compared with the exact 50.73%. It helps explain the pattern; it does not replace the exact result. It becomes less accurate as the fractions k/365 stop being small.
The number of pairs grows quadratically. The probability does not keep growing quadratically or exponentially. It rises toward 100% and eventually flattens out.
Try it in Python
You don’t need enormous factorials to calculate the exact model probability. Multiply the no-match factors directly:
from math import prod, comb, exp
def shared_birthday_probability(n: int) -> float:
if n < 0:
raise ValueError("The number of people must be non-negative.")
if n > 365:
return 1.0
return 1 - prod((365 - k) / 365 for k in range(n))
n = 23
exact = shared_birthday_probability(n)
approx = 1 - exp(-comb(n, 2) / 365)
print(f"Pairs: {comb(n, 2)}")
print(f"Exact: {exact:.2%}")
print(f"Approximation: {approx:.2%}")
The output is 253 pairs, an exact probability of 50.73%, and an approximation of 50.00%. Try 10, 30, and 50 people before checking the chart. Does your intuition improve once you think in pairs?
One last comparison
Among 23 people, any pair sharing a birthday has a probability of about 50.73%.
But if you stand in a room with 22 other people, the chance that at least one shares your particular birthday is:
Same room. Different question. Very different answer.
That distinction is what I like about this puzzle. The mathematics is accessible, but it asks us to notice an assumption hiding in our first impression.
The surprise comes from counting people when we should be counting pairs.