Birthday Paradox Explorer

shared birthday probability vs group size

Loading interactive simulation...

Lesson

The theory β€” Birthday Paradox Explorer

The birthday problem asks for the probability that at least two people anywhere in the group share a birthday. It is not the probability that someone matches you, and it is not about any particular date β€” that distinction is the whole reason the answer feels wrong.

What each symbol means

P(match)
the probability that some pair shares a birthday β€” the headline figure, 50.7% at n = 23.
P(all unique)
the probability that no two people share one. The two always add to 100%: 50.7% + 49.3%.
pairs
how many pairs the group contains, n(nβˆ’1)/2 β€” at 23 people that is 253, and it is pairs rather than people that drives the probability up.

How to read what you see

The two probabilities come first, then the pair count, then a numbered walk-through. Below that the formula shows exactly what was multiplied: 1 βˆ’ (365/365 Γ— 364/365 Γ— β‹― Γ— 343/365), one factor per person, ending at 1 βˆ’ 0.492703 = 0.507297. Each factor is the chance the next person misses every birthday already taken.

Assumes
365 equally likely birthdays, independent between people. No leap days, no twins, and no seasonal pattern in births β€” all three are false in the real world, which is why this is a clean model rather than a demographic prediction.
Breaks when
The uniform assumption is not conservative in the direction you might guess. Real birth dates clump seasonally, and any departure from uniformity raises the chance of a collision β€” so 50.7% at 23 people is a floor, not an estimate. Push the slider to 80 and the probability rounds to 100%, but it never actually reaches it: with fewer than 366 people a no-match outcome always remains possible.

the paradox of pairs, not people 🖖

The paradox dissolves once you stop counting people and start counting pairs. With 23 people there are only 23 birthdays to compare, but C(23,2) = 253 distinct pairs that could each turn up a match β€” and it only takes one. Human intuition anchors on 'how many people are like me,' which grows linearly, while the quantity that actually matters, the number of pairwise comparisons, grows quadratically as n(nβˆ’1)/2. That's why the probability curve rockets upward so early: past n=23 you've already crossed 50%, and by n=57 it's over 99%, because you're feeding the problem O(nΒ²) worth of opportunities to collide.

why we compute the opposite 🖖

Instead of tracking every way a match could appear, the tool asks the far easier reverse question: what's the chance everyone's birthday is different? Add people one at a time β€” the second must miss 1 taken day (364/365), the third must miss 2, and so on β€” then multiply those shrinking fractions and subtract from 100%. The takeaway: at 23 people the 'all different' chance finally dips below half, which is exactly why 23 is the tipping point.

the same math cracks cryptography 🖖

The identical logic quietly governs digital security. To break a hash function an attacker rarely needs a specific target β€” any two inputs that produce the same output will do, which is precisely the 'any pair' problem. So a hash with N possible outputs falls to a birthday attack after roughly √N attempts, not N. That's why a 256-bit hash gives only about 128 bits of collision resistance, and why designers must double the length to stay safe.

Practice

Check yourself

Predict the answer first, then use the controls above to find out. Reveal only after you have committed to a guess β€” that is what makes it practice.

  1. Ten people make 45 pairs, and each pair has about a 1-in-365 chance of matching β€” which suggests 45/365 = 12.3%. The panel says 11.7%. Which way is the quick estimate wrong, and why is it wrong in that direction?

    Show answer
    It overestimates, and it always will. Adding up 45 pair-chances counts every double coincidence more than once: that sum is the first term of an inclusion–exclusion series whose next term subtracts. The panel goes the honest way round instead β€” P(all unique) = (365/365)(364/365)…(356/365) = 88.3%, and 100% βˆ’ 88.3% = 11.7%. The gap widens fast: at 23 people the quick sum gives 253/365 = 69.3% against a true 50.7%, and once a group has more than 365 pairs the quick sum sails past 100%, which is the plainest possible proof that it was never a probability.
  2. Push the group size to its maximum of 80. P(shared birthday) reads 99.99% β€” not 100%. How many people does it take before a shared birthday is genuinely certain?

    Show answer
    366, or 367 once you allow 29 February. That is the pigeonhole principle, and it is the only route to certainty: with 365 possible dates, 366 people cannot all be different. Everything below that is merely likely, however close it looks. The slider stops at 80 because that is where the curve does its work β€” it is already at 99.99% there, and the remaining 286 people buy only the last hundredth of a percent. Watch the panel add a second decimal at n = 73 rather than print a 100% it cannot justify.

Problems solved in full

  1. 23 people in a room with a shared birthday 5 steps

    How many people must be in a room before a shared birthday is more likely than not? Derive it, then explain why 23 feels far too small.

    1. Compute the opposite. β€œAt least one shared” is awkward because the sharing can happen in many ways at once; β€œall different” is a single clean sequence of choices.

    2. Each new person must avoid all the birthdays already taken, so the available days shrink by one each time. Multiply the fractions.

    3. Subtract from one. The explorer above prints exactly this, and 23 is the first n for which the result passes a half.

    4. You are not comparing yourself with 22 others β€” every pair counts, and the number of pairs grows as the square of the group.

    5. That squared growth is visible in the approximation: the probability depends on nΒ² over 730, so the crossing point goes as a square root, not a fraction of 365.

    Answer

    23 people, for a 50.7% chance. The intuition that fails is a question-substitution: people picture "someone shares my birthday", which needs 253 people for even odds, when the question asked is "any two of us", which has 253 pairs at n = 23. The square-root scaling is the general lesson, and it is why hash collisions appear after roughly √N insertions rather than N β€” the same arithmetic decides how long a hash needs to be.

  2. The 50.7% rule for twenty-three people in a 365-day year 6 steps

    Twenty-three people, 50.7%. The number everyone remembers is 23, and it is the least useful part of the result β€” it belongs to a 365-day year and nothing else. Find the rule underneath it, the one that still holds when the calendar is a hash function.

    1. The exact answer is a product: the second person misses the first, the third misses both, and so on down the room. That product is what the panel evaluates.

    2. Products are hard to reason about, so take logarithms β€” and while k is small against 365, each logarithm is very nearly its own argument. What is left is a sum of the first nβˆ’1 integers.

    3. Set the probability to a half and solve. The nΒ² term dominates the n, so the answer is a square root, and it lands within half a person of the 23 on the panel.

    4. Now write it with no 365 in it. The year was never special: for N equally likely slots the halfway point sits at about 1.1774√N.

    5. Apply that where it actually bites. A 32-bit hash has 2Β³Β² slots, which sounds enormous β€” but the square root of an enormous number is not enormous.

    6. Measure that against the size of the space it is drawn from.

    Answer

    The threshold grows like √N, not like N/2 β€” and for a 32-bit hash that means 77,162 items, 0.0018% of the space, before a collision is more likely than not. That is the birthday attack, and it is why 32-bit checksums are useless for deduplicating anything at scale, and why hash outputs are sized in bits with the square root already assumed. The 23 on the panel is a single point on that curve. The curve is the part that transfers.

Learning path

When two things land on the same value

Leads to Hash tables the pair-counting argument and the habit of computing the complement β€” the chance that nothing collides.

References (1)

Example problems

  • office n=10 - n=10 -> 11.7% chance - feels safe, but 45 pairs are already being compared
  • class n=23 - n=23 -> 50.7% chance - the famous crossover: more likely than not
  • room n=30 - n=30 -> 70.6% chance - roughly 2-in-3 for a typical classroom
  • hall n=57 - n=57 -> 99.0% chance - near-certainty with just 57 people