How Many Random Picks Before Two Results Match? The Birthday Problem for PINs and Dice
Among a group generating independent 4-digit PINs from 10,000 possibilities, only 119 people are needed before there is a better-than-50% chance that at least two of them land on the exact same PIN — a number that surprises most people because it grows roughly with the square root of the space, not with the space itself, the same birthday-problem arithmetic behind why 23 people give better-than-even odds of a shared birthday.
A worked example with numbers
The probability that n independent picks from d equally likely possibilities are all different is the product (d/d) × ((d−1)/d) × ((d−2)/d) × … × ((d−n+1)/d); one minus that product is the probability of at least one repeat. For d = 10,000 four-digit PINs, working through that product shows the probability of at least one shared PIN crosses 50% at n = 119 people, reaching exactly 50.58% at that point — up from 39.14% at 100 people and 11.55% at 50 people. The common intuition that “it would take thousands of people” badly underestimates how fast the collision probability rises, because the number of possible pairs among n people grows roughly as n²/2, not as n — doubling the group size roughly quadruples the number of chances for a match, not merely doubles it.
How to set the rule before the result
A quick, commonly cited approximation for the 50%-collision point is n ≈ 1.1774 × √d, which for d = 10,000 gives 1.1774 × 100 = 117.74, close to the exact value of 119 found by direct calculation above. To verify a specific case, compute the exact product directly rather than relying only on the approximation when precision matters — the approximation is accurate to within a person or two for the PIN example but can drift further off for very small values of d, where the exact product-based calculation is cheap enough to run directly.
Common mistakes that change the odds or the process
A common mistake is comparing this collision probability to the much smaller-sounding chance that two specific named people share the same PIN, which is only 1/10,000 = 0.01% — a completely different question. The birthday-style calculation asks whether any two people out of the whole group match, and there are many more possible pairs than there are people, exactly why the group-wide answer is so much larger than the specific-pair answer. A second mistake is assuming this collision math describes a PIN reset or lockout system, where a match against one specific stored value matters — that is the smaller 1/d-per-attempt question, not the birthday-style group question, and conflating the two leads to badly miscalibrated security assumptions in either direction. A third mistake is assuming a collision means something is broken; with independent random PINs, occasional matches are the expected, mathematically predictable behaviour of the system, not a sign that the PIN generator has failed.
Where this method stops being appropriate
This calculation assumes every pick is independent and drawn uniformly from the stated space; a system that avoids reissuing an already-used PIN — checking each new pick against every previous one and rerolling on a match — has no collision probability at all by construction, a different and stronger guarantee than the plain independent-draws case analysed here. It also assumes the full stated space is genuinely reachable; a PIN generator that silently avoids certain digit patterns, such as repeated digits or ascending sequences, is drawing from a smaller effective space than 10,000, which lowers the number of people needed to reach 50% collision odds below the 119 calculated above.
How the random source fits into the rule
MDN’s Crypto.getRandomValues reference documents the browser’s cryptographically strong source most independent PIN generation should draw from; the same birthday-style collision arithmetic is applied at a much larger scale to UUID collision risk in the site’s own UUID uniqueness guide.
Collision probability at a few group sizes, 4-digit PINs
| People | P(at least one shared PIN) |
|---|---|
| 50 | 11.55% |
| 100 | 39.14% |
| 119 | 50.58% |
| 150 | 67.47% |
| 200 | 86.51% |
The probability climbs steeply once the group passes roughly the square root of the total space (100, for 10,000 possibilities) — going from 50 to 200 people, a fourfold increase in group size, moves the collision probability from barely more than one in nine to nearly seven in eight.
The name “birthday problem” comes from the classic version of this question: among 23 people, each with a birthday uniformly distributed across 365 days (ignoring leap years), the probability that at least two share a birthday is about 50.73% — barely half, despite 23 feeling like a small group next to 365 possible days. Raising the group to 30 people pushes the shared-birthday probability to about 70.63%. The PIN and dice examples above are the identical calculation applied to different values of d, which is why the same square-root-scaling intuition — needed group size grows roughly with √d, not with d — carries over from birthdays to PINs to dice sequences without any change to the underlying formula. That scaling is also why a 6-digit PIN space of 1,000,000 possibilities needs a much larger group — about 1,178 people — before crossing the same 50% collision threshold that only 119 people reach at 4 digits, a tenfold jump in space producing roughly a tenfold jump in the group size needed, consistent with the √d relationship throughout.
A second case: three stacked d6 rolls instead of PINs
Rolling three six-sided dice and reading them as an ordered sequence gives 6³ = 216 equally likely outcomes — a much smaller space than 10,000 PINs. Applying the same collision arithmetic, the 50%-collision point falls at just 17 people rolling independently: at 10 people the collision probability is 19.06%, at 17 it crosses 47.60%, and at 20 it reaches 59.64%. A smaller possibility space needs proportionally far fewer independent draws before a repeat becomes likely, following the same square-root relationship — √216 ≈ 14.7, close to the exact 17-person threshold found directly, the same pattern seen in the PIN example at a different scale.
Why this is not the right model for guessing a single target PIN
An attacker trying to guess one specific person’s stored PIN is solving a different problem: with no lockout, each independent guess has a flat 1/10,000 = 0.01% chance of matching that one target, and reaching even a 50% chance of success needs about 6,932 guesses — nowhere near the 119-person collision threshold above, because guessing one fixed target is a single-comparison problem while the birthday-style question compares every pair within a whole group at once. Real PIN and password systems address the single-target scenario with attempt limits and lockouts specifically because, unlike the birthday-collision case, a determined attacker facing no limit will eventually succeed at the single-target guess given enough tries.