Generalised Birthday Collision Calculator

The birthday problem shows that shared values appear far sooner than intuition suggests. Enter the number of categories d (365 for calendar birthdays, or a hash space size for cryptography) and the number of items k. The calculator returns the exact probability that at least two items collide, the probability that all items are distinct, and the approximate number of pairs that could collide. With only 23 people among 365 days the collision probability already passes 50 percent, the same square-root behaviour that drives the birthday attack on hash functions.

0.00
0.00
0.00
0.00

Birthday collision formula

P(all distinct) = product over i from 0 to k-1 of (d - i) / d
P(at least one collision) = 1 - P(all distinct)
Number of pairs = k * (k - 1) / 2

The distinct probability multiplies the chance each new item avoids every value already taken. As k grows, each new factor shrinks, and the product falls below one half remarkably quickly relative to d.

Key facts

  • For d = 365 and k = 23, the collision probability is about 50.73 percent.
  • For d = 365 and k = 57, the collision probability exceeds 99 percent.
  • Roughly 1.18 times the square root of d items gives a 50 percent collision chance.
  • If k is greater than d, a collision is guaranteed (probability 1) by the pigeonhole principle.
  • This square-root scaling underlies the birthday attack on cryptographic hash functions.

Birthday collision: frequently asked questions

What is the birthday problem?

The birthday problem asks how likely it is that, in a group of people, at least two share a birthday. With 365 equally likely days and just 23 people the probability already exceeds 50 percent. This calculator generalises it to any number of categories d and any number of items k.

What is the exact formula?

The probability of no collision is the product (d/d) times ((d-1)/d) times ... times ((d-k+1)/d). The probability of at least one collision is 1 minus that product. This is exact under the assumption that all d categories are equally likely and items are independent.

Why does a collision become likely so fast?

Collisions depend on the number of pairs of items, which grows roughly as k squared divided by 2. With many pairs each having a small chance of matching, the combined probability rises quickly. This is why hash collisions and birthday matches happen sooner than intuition suggests.

What can I use the category count d for?

Set d to 365 for the classic birthday problem, or to the size of a hash space (for example 2 to the power of the number of output bits) to estimate cryptographic collision risk, or to any number of equally likely buckets in a load-balancing or sampling problem.

What happens when k exceeds d?

If the number of items k exceeds the number of categories d, a collision is certain by the pigeonhole principle, so the probability is exactly 1. The calculator returns 1.00 in that case.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 16 June 2026. See our methodology.