Probability Theory

The Birthday Problem

How many people do you need in a room before two of them share the same birthday?

23

people is enough for a 50% chance
of a shared birthday — not 183.

Why So Few?

The intuitive guess is around 183 — half of 365. But that answers the wrong question. We're not asking "does anyone share my birthday?" — we're asking "does any pair share a birthday?" The number of pairs grows much faster than the number of people.

n(n − 1) / 2 pairs with n people
253 pairs with just 23 people

Where does n(n − 1) / 2 come from? Each of the n people could pair with any of the other n − 1 people, giving n × (n − 1) ordered combinations. But Alice→Bob and Bob→Alice are the same pair, so we divide by 2 to avoid counting each pair twice.

Each of those 253 pairs has a ~0.27% chance of sharing a birthday. 253 independent chances add up fast — which is why the total probability crosses 50% much sooner than intuition suggests.

Interactive Calculator

Number of people 23
1 25 50 75 100
50.7% probability of at least one shared birthday
Possible pairs 253
P(no shared birthday) 49.3%

The Probability Curve

The curve rises steeply and reaches near-certainty well before 100 people. Drag the slider above — the vertical marker follows.

The Mathematics

We compute the probability that no one shares a birthday, then subtract from 1. Each new person must avoid all birthdays already taken:

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

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

The k-th person has a (365 − k + 1) / 365 chance of not matching anyone already in the room. Multiplying these together for k = 1 to n gives P(no match). For n = 23, this product drops just below 0.5.

Key Thresholds

10
11.7%
20
41.1%
23
50.7% — tipping point
40
89.1%
57
99.0%
70
99.9%

Why It Matters

Cryptographic Hash Collisions

A birthday attack exploits this principle to find collisions in hash functions. A hash with n bits has 2n possible outputs, but you only need roughly 2n/2 inputs to reach a 50% chance of collision. This is why SHA-256 (256-bit) provides only 128-bit collision resistance.

Passphrase & Password Security

When generating passphrases from large wordlists, the birthday problem determines how many can be safely issued before two users share one. A BIP39 12-word phrase from a 2048-word list gives ~2132 possibilities — requiring ~266 generations before expecting a collision. Safe at any realistic scale.

Random ID Collisions

UUID v4 uses 122 random bits, giving ~5.3 × 1036 possibilities. You need to generate about 2.7 × 1018 UUIDs before reaching a 50% collision probability — entirely safe for any real-world application.