It is the first week of Grade 9 at a school in Bhaktapur, and the class teacher is filling in the register: names, roll numbers, dates of birth. There are 23 students. Kabita, at the front, says she is sure two of them have the same birthday. Suman laughs. “There are 365 days in a year and only 23 of us. Two of us on the same day? Never.” He offers her a bet, his samosa against hers.
Who should take the bet? Before you think about it for long, try it. Fill a class with random birthdays and see how often two of them land on the same day.
Guess first. How many people must be in a room before it is more likely than not that two of them share a birthday?
Pick an answer to see why.
Try it with a smaller year
Three hundred and sixty-five days is a lot to think about. Shrink the year first.
A year of six days. Roll a die for each person: the number it shows is their “birthday”. With two dice, the chance they show the same number is 1 in 6. With three dice? Count. There are 6 × 6 × 6 = 216 ways the three dice can fall, all equally likely. The ways with all three different: the first die can show anything (6 ways), the second must miss it (5 ways), the third must miss both (4 ways): 6 × 5 × 4 = 120. So
Four dice: 6 × 5 × 4 × 3 = 360 of the 6⁴ = 1,296 ways are all different, so a match comes up 1 − 360/1,296 = 13/18, about 72% of the time. Four people, a year of six days, and a shared “birthday” is already likely.
A year of twelve months. Now ask about birth months instead of days. The same counting works: the chance that n people all have different months is , one factor for each person.
| People | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 |
|---|---|---|---|---|---|---|---|---|---|
| Chance two share a birth month | 8.3% | 23.6% | 42.7% | 61.8% | 77.7% | 88.9% | 95.4% | 99.99% | 100% |
Five people are enough to make a shared month more likely than not. But look at the last two columns. With 12 people, a shared month is very nearly certain, 99.99%, but not quite: all twelve could have been born in twelve different months (about 1 chance in 18,600). Only with 13 people is it certain, because twelve months can’t each hold one of 13 people without one month getting two. That argument, the pigeonhole principle, gives certainty and has a topic of its own (Must Two People Here Share a Birthday Month?, below).
Your school assembly has 400 students. Which is true?
Pick an answer to see why.
Why your gut says 183
Where does the guess of 183 come from? Most people, asked about a shared birthday, quietly picture themselves: “How many people would I need to meet before one has my birthday?” Each other person has 1 chance in 365 of being born on your day, so it feels as if you would need about half of 365 people to have an even chance.
Even that guess is too small, as it happens. The chance that nobody among k others has your birthday is , since each of them, independently, must miss your day. In a class of 23, you have 22 classmates: , about 1 chance in 17. For the chance to pass a half you would need 253 other people, not 183, because some of those people share birthdays with each other and so “use up” fewer days.
But Kabita’s bet isn’t about her birthday. It is won by any two people sharing a day: Suman and Pasang, Rita and Bibek, anyone. So count the pairs. Each of the 23 can pair with 22 others, which is 23 × 22 = 506, but that counts every pair twice (Kabita with Suman, and Suman with Kabita), so
If you know combinations, this is , the number of ways to choose 2 people out of 23. It is also the handshake count: if everyone in the class shook hands with everyone else once, there would be 253 handshakes. Every pair is one more chance of a match.
With 23 people you are in 22 pairs, but the class has 253. When the class doubles to 46 people, your pairs about double, from 22 to 45, while the class’s pairs go up more than four times, to 1,035. The number of pairs grows like the square of the number of people. That is where intuition goes wrong: we think about the people, and the chance depends on the pairs.
A class has 30 students. How many pairs of students are there?
Pick an answer to see why.
Working out the exact chance
So many pairs makes a match likely, but how likely? Adding up the pairs’ chances runs into trouble at once (see the box below). The clean way is the one the dice used: work out the chance that everyone is different, then take it from 1. “At least one match” and “all different” are complements: exactly one of them happens.
Line the people up in any order, the register’s will do, and take them one at a time.
- The 1st person can have any birthday: chance .
- The 2nd must miss the 1st person’s day: 364 of the 365 days do, chance .
- The 3rd must miss two days, given that the first two are already different: chance .
- …and so on, until the 23rd must miss 22 different days: chance .
Each step is a chance given that everything before it went right, so the steps multiply. This is the multiplication principle of probability from Grade 10, in its general form for events that depend on each other: P(A and B) = P(A) × P(B given A). Strung together over 23 people:
So the chance of a shared birthday is 1 − 0.4927 = 0.5073, or 50.7%. Kabita’s bet is a little better than even. With 22 people it would be 47.6%, just under even; 23 is the first class size where the match is more likely than not.
Each factor is close to 1, so the product shrinks slowly at first: 99.7% after two people, 97.3% after five. But there are 23 of them, each a little smaller than the last, and together they bring it under a half.
If you know permutations (Grade 12), the same product is a count. The number of ways 23 people can have 23 different birthdays, in order, is ; the number of ways they can have birthdays at all is . Each is a number of 59 digits, and the chance is their ratio, : the same 0.4927.
| People in the group | 5 | 10 | 15 | 20 | 23 | 30 | 40 | 50 | 57 | 70 |
|---|---|---|---|---|---|---|---|---|---|---|
| Chance of a shared birthday | 2.7% | 11.7% | 25.3% | 41.1% | 50.7% | 70.6% | 89.1% | 97.0% | 99.0% | 99.9% |
Figure 12.1 shows how sudden it is. With 10 people a match happens about one time in nine; by 40, nine times in ten. A class of 40, common in Nepal’s schools, almost always has a pair.
A shortcut: the square root
Here is a way to see why the answer is about 23, without the long product. Pretend for a moment that the pairs were separate. Each pair misses with chance , so all 253 would miss with chance
That is very nearly the true 0.4927: when matches are rare, the pairs behave almost as if they were separate. Now look at the shape of this. A number just under 1, , raised to the power 365 is about 0.367, and the same happens for any big number: settles near 0.368 as d grows (this number is 1 ÷ e, from the topic What Is e?). Our power, 253, is 0.69 of 365, and . So the chance of no match falls to about a half when
For 365 days, : about 23 people. The rule says something you can carry about: a match becomes likely once the number of people is about the square root of the number of possible values, not half of it. Half of 365 is 183; the square root of 365 is 19. That gap is the whole surprise.
| Possible values d | 6 (a die) | 12 (months) | 100 | 365 (days) | 10,000 |
|---|---|---|---|---|---|
| 2.9 | 4.1 | 11.8 | 22.5 | 118.0 | |
| Fewest people for a better than even chance (exact) | 4 | 5 | 13 | 23 | 119 |
The rule is a little low for small d, and very close for large ones, which is exactly where it is used.
Real birthdays
Every calculation so far assumes that each of the 365 days is equally likely, that 29 February doesn’t exist, and that the people’s birthdays have nothing to do with each other. Real birthdays break all three rules. How much does it matter?
- Uneven birthdays. Births aren’t spread evenly over the year: some months have more than others. But unevenness can only raise the chance of a match. If birthdays crowd onto some days, those days fill up with pairs sooner. Mathematicians have proved that this always holds (David Bloom, 1973; the proof needs more algebra than this page), so the even spread is the hardest case, so 23 people are, if anything, more than enough. Real birthdays turn out not to be uneven enough to change the answer: a study of real birth records found it is still 23.
- 29 February. With 366 equally likely days instead of 365, the chance for 23 people is 50.6% instead of 50.7%, and the first group over a half is still 23. (Treating 29 February as just as likely as other days even overstates its effect: it comes once in four years.)
- Other calendars. Many families in Nepal keep birthdays by Bikram Sambat. Its months have 29 to 32 days, but its year has 365 or 366 days, so the answer is the same. (Your BS birthday and your AD birthday don’t stay on the same pair of dates from year to year; see What Day of the Week Will Your 100th Birthday Be?)
- Twins. A pair of twins in a class makes a match certain. Real classes, with twins, are a little more likely to have a match than the sums say.
The same squads hint at uneven birthdays: in 2014 the players’ birthdays crowded into the early months of the year (77 in February, 46 in October, against an even 61 a month), perhaps because in youth football the oldest children in each year’s age group, born just after the cut-off date, are picked more often. More or Less called it “a quick look … not a definitive analysis”.
More puzzles of the same kind
Three on the same day. How many people do you need before it is more likely than not that three share a birthday? The pairs had it easy: a triple needs two coincidences at once. The answer, counted exactly (in the script behind this page), is 88. With 23 people a triple happens only about 1.3% of the time.
Nearly the same day. Call two birthdays “close” if they are on the same day or on next-door days (the 4th and the 5th, or 31 December and 1 January). Each person now blocks three days instead of one, so close birthdays come much sooner: 14 people give a better than even chance of two close birthdays. Within a week of each other (seven days apart or less): just 7 people (60.6%).
First to match. People walk into an empty room one at a time and say their birthdays. Who is most likely to be the first to match someone already in the room? Not the first few (too few birthdays to match), and not the 50th (by then someone has almost certainly matched already). The answer is the 20th person: the chance that the first match comes exactly at them is the highest of anyone’s.
Which is more likely: that two students in a class of 30 share a birthday, or that one of 300 students in a school shares the principal’s birthday?
Pick an answer to see why.
A story from maths
Where this is used
Collisions also matter inside every program that stores data in a hash table, the way Python’s dictionaries find a key at once: with 365 buckets, 23 keys are already more likely than not to put two in one bucket. That is why hash tables are built to handle collisions rather than to avoid them (Grade 11 Computing, Hash tables).
Questions
★ Four friends were born in the same year. What is the chance that at least two of them were born on the same day of the week?
Pick an answer to see why.
Use the table above. In a class of 40, about how often would two students share a birthday? And in a class of 15?
Hint
Answer
Show that with 5 people the chance of a shared birth month (twelve equally likely months) is .
Hint
Answer
A school gives every student a four-digit locker code, 0000 to 9999, chosen at random. About how many students must there be before it is more likely than not that two have the same code?
Hint
Answer
Explain why 253 people are needed for an even chance that someone shares your birthday, and not 365 ÷ 2 ≈ 183.
Hint
Answer
A program gives each photo it stores a random 32-digit binary label (a 32-bit number, 4,294,967,296 possible values). The programmer says: “With fewer than a few billion photos, two will never get the same label.” Is that right? Roughly how many photos make a repeated label more likely than not?
Hint
Answer
In a group of 23, what is the average number of pairs with the same birthday? Use it to explain why the average can be 0.69 while the chance of at least one pair is only 0.51.
Hint
Answer
Where to go next
- Must Two People Here Share a Birthday Month? The pigeonhole principle: when a match is certain, not just likely, and how far that simple idea reaches.
- Should You Switch Doors? Another chance that everyone’s gut gets wrong, and how to check it by counting.
- Is a Positive Test Result Bad News? Conditional probability, the multiplication principle’s other half, in medical tests.
- What Is e, and Why Does Growth Keep Finding It? Where the 0.368 of the square root rule comes from.
- How Many Handshakes at a Party of 30? (Grades 6–8) Counting pairs, the 253 of this page.
- Which Total Comes Up Most with Two Dice? (Grades 6–8) Counting equally likely outcomes, as the dice did here.
- Grade 10 Math: Multiplication principle of probability The rule the exact chance is built on.
- Grade 11 Computing: Hash tables Collisions in practice.
- Computing, Going Further: How Does a Computer Roll a Die? Random numbers, the kind the class-filling widget uses. (Coming soon.)
Where these facts come from
- The problem, the exact product for 23 (0.4927), 253 pairs, unevenness only raising the chance (proved by D. Bloom, “A Birthday Problem”, American Mathematical Monthly 80 (1973), as the article cites it) and real birthdays still needing 23 (M. Cortina Borja and J. Haigh, “The Birthday Problem”, Significance 4 (2007), as cited there), the near-match formula (Abramson and Moser, 1970), 88 people for three sharing, the 20th person most likely to be the first match, 253 for your own birthday, the birthday attack, Davenport’s attribution and von Mises’s 1939 publication: Wikipedia, “Birthday problem”, read October 2026.
- The history (Tyson’s 1983 letter, Anne Davenport’s 1984 letter, Coxeter’s and Rogers’s doubts that Davenport invented it, Ball’s 11th edition of 1939 edited by Coxeter, von Mises in the Revue de la Faculté des Sciences de l’Université d’Istanbul 4 (1938–39) and the group of 60 with three birthdays alike, Halmos’s problem 4177 of 1945, Gamow’s 24): David Singmaster, Sources in Recreational Mathematics, 8th preliminary edition (2004), section 8.B, “Birthday problem”, read October 2026.
- Von Mises’s move from Germany to Istanbul in 1933 and to the United States in 1939: MacTutor, “Richard von Mises”; Davenport’s dates and field: MacTutor, “Harold Davenport”, read October 2026.
- The 2014 World Cup (32 squads of 23, 16 with a shared birthday, five with two pairs, 31 of 64 with 2010, Hulk and Paulinho, Gago and Fernández, the birth months, “a quick look”): James Fletcher, “The birthday paradox at the World Cup”, BBC News, 16 June 2014, read October 2026.
- The birthday attack and collisions after about tries: Wikipedia, “Birthday attack”, read October 2026. SHA-1’s 160 bits and browsers ending SHA-1 certificates in 2017: Wikipedia, “SHA-1”, read October 2026.
- The SHA-1 collision (February 2017, CWI Amsterdam and Google, two PDFs, 9,223,372,036,854,775,808 computations, “more than 100,000 times faster than a brute force attack”, SHA-256 as a safer choice): Google Security Blog, “Announcing the first SHA1 collision”, 23 February 2017, read October 2026.
- Bikram Sambat years of 365 or 366 days: the calendar tables of the Python package nepali-datetime 1.0.8.5 (2000–2083 BS).
- Every number on this page (the dice and months tables, 4/9 and 13/18, 1 in 18,600, the 23-person product and its table, 22 and 23 people, 253 and 5.9%, the pairs counts, 0.4995 and 0.368, the square root table, the phone endings, 366-day years, 88 for three, 14 and 7 for close birthdays, the 20th person, 56.1% for the principal, the World Cup’s expected 16.2, the 32-bit 77,000, and , and every answer to the questions) was computed by a script (
checks/textbooks/math-further-9-12/12/tmp/answers.py).
