On this page
Ask a class how many people you need before two of them probably share a birthday, and it is tempting to guess something near half of 365. The real answer is far smaller, and the best way to believe it is to test it yourself before doing the algebra. Below is a ten-minute simulation, then the exact calculation, step by step.
How many people do you need for a 50 percent chance of a shared birthday?
Ignoring leap years and assuming every day is equally likely, a group of 23 people has a 50.7% chance that at least two share a birthday (Wikipedia: Birthday problem).
The same source gives the rest of the curve: 10 people give 11.7%, 30 people give 70.6%, 40 people give 89.1%, and 70 people give 99.9% (Wikipedia: Birthday problem). So a school section of 40 students is very likely to contain a shared birthday, and in a room of 70 it would be a surprise not to find one.
How do you simulate random classrooms?
A simulation means building many pretend classrooms with random birthdays and counting how often a match turns up. Here is a version that needs only a spreadsheet.
In Google Sheets or Excel, fill cells A1 to A23 with =RANDBETWEEN(1,365). Each cell is one student's birthday, as a day number.
In B1, type =IF(COUNTA(UNIQUE(A1:A23))<23,1,0). It shows 1 if two days repeat and 0 if all 23 are different.
Press recalculate (F9 in Excel, or edit any cell in Sheets) and note the 0 or 1. Each press is a new classroom.
Record 50 classrooms and count the 1s. Then repeat with 10, 30 and 40 students by changing the range and the number 23.
With only 50 runs your share will wobble around the true value from one batch to the next; that wobble is the point. Pool results across the class and the estimate settles, which is the law of large numbers at work (see our post on Jacob Bernoulli and the law of large numbers).
Some ideas are easier to see than to read, and the Fermi Simulation Lab has interactive simulations built for exactly that.
How does the complement rule give the exact probability?
The complement rule says P(at least one shared birthday) = 1 minus P(all birthdays different), because those two events cover every case and cannot both happen (Wikipedia: Birthday problem). "At least one match" has many messy cases; "no match" has exactly one, so you count that instead.
Worked example for 23 people:
Person 1 can have any birthday: probability 365/365.
Person 2 must avoid person 1's day: 364/365.
Person 3 must avoid both: 363/365.
Continue until person 23, who must avoid 22 days: 343/365.
Multiply: P(all different) = (365 x 364 x ... x 343) / 365^23, which is about 0.493.
Subtract from 1: P(shared) is about 1 - 0.493 = 0.507, or 50.7%.
Run the same steps with 22 people and the answer drops just below one half (about 47.6%), which is why 23 is the threshold. A common slip is multiplying chances for each pair as if pairs were independent; our guide to independent vs mutually exclusive events explains why that does not work, and five probability reasoning mistakes in JEE maths covers the "at least one" trap in general.
Why does 23 feel far too small?
Your intuition counts people, but matches come from pairs. Among 23 people there are 23 x 22 / 2 = 253 pairs, and each one is a chance for a match (Wikipedia: Birthday problem). Pairs grow roughly with the square of the group size, so the probability climbs fast and then flattens near 100%.
What about real birthdays, which are not spread evenly across the year? Statisticians Mario Cortina Borja and John Haigh explain the birthday problem in the journal Significance (Cortina Borja and Haigh, 2007). Any unevenness makes a match slightly more likely, but real birthdays are not uneven enough to change much: the real-world group size needed for a better-than-even chance is still 23 (Wikipedia: Birthday problem).
What should you try next?
Find the smallest group where your simulation gives a match more than 90% of the time, then check it with the complement rule.
Change 365 to 12 and ask about shared birth months. Predict the threshold before you compute it.
Ask a different question: how many people do you need before someone shares your own birthday? The answer is much larger; working out why tests whether you understood the pairs argument.
If you get stuck between the simulation and the formula, Fermi's AI tutor works out what you already know and builds a plan for the session, so you can pick up from the step that confused you.



