Main menuGallery

Birthday Problem

Birthday problem

People in the room: 30
Question
Run
Numbers

Drag the slider (or press ← →) to change the class size; press R to run a room, M for 1 000 rooms.

What's the maths?

Where's the maths? This is probability — the branch of mathematics that measures how likely something is on a scale from 0 to 1. Each person on screen is given one birthday out of 365 equally likely days, so a single day is a simple event with probability 1/365. The surprise is about a pair: we are not asking whether anyone matches one chosen date, we are asking whether any two of them match, and a room of 23 people already hides 253 different pairs. The clean way to handle "at least one match" is to work out the opposite — everybody different — by multiplying probabilities one person at a time, then subtract from 1. That multiplication rule for independent events, and the complement rule P(at least one) = 1 − P(none), are exactly the tools in the syllabus. Running a thousand rooms then shows the law of large numbers: the measured fraction settles onto the calculated curve.

📚 On the Sec 1–4 syllabus
  • Sec 2 · S2 Probability — 2.1 probability as a measure of chance; 2.2 probability of single events (listing all the possible outcomes)
  • Sec 3/4 · S2 Probability — 2.4 multiplication of probabilities for independent events (and the complement “at least one”)

Beyond the syllabus: factorials and the general product formula.

Seat the people one at a time and ask each one to be different from everyone already seated. The 1st person may take any day: 365/365. The 2nd must dodge 1 day: 364/365. The 3rd must dodge 2 days: 363/365 — and so on. Because the birthdays are independent, these chances multiply:

P(no match) = 365/365 × 364/365 × … × (365−n+1)/365

Every factor is a little smaller than the one before, so the product slides downhill fast. Then use the complement — the two outcomes "no match" and "at least one match" fill the whole sample space:

P(at least one shared birthday) = 1 − P(no match)

At n = 23 the product falls just below 1/2, so P(shared) = 50.7 % — the 50 % crossing marked on the graph. By n = 41 it is 90 %, and by n = 60 it is over 99 %. The reason it happens so early is pairs: n people make n(n−1)/2 pairs, which is 253 pairs at n = 23 and 1 128 pairs at n = 48 — the count of chances grows like n², not like n.

Switch to “Same as YOU” and the maths changes completely: now only the pairs that include you count, so each other person misses your date with probability 364/365 and P(match) = 1 − (364/365)n−1. You need 253 other people to reach 50 %. That gap — 23 against 253 — is why the answer feels wrong: our intuition quietly answers the "same as me" question instead.

Try this. Set the class to 23, press Run 1 000 rooms and check that the blue dot lands on the gold curve near 50 %. Now guess the answer for 41 people before you move the slider — then run it. Finally switch to Same as YOU at 23 people and see the probability collapse to about 6 %.

Drag the slider to set the class size · Run once fills the seats one by one · Run 1 000 rooms adds a measured point to the graph.

Gold: exact curve · blue dots: measured from simulated rooms.