Skip to content

Birthday Paradox Calculator

The chance that two people in a group share a birthday, how many people you need for a 50% or 99% match, and the same maths for hash collisions.

Calculator Details

Chance at least two of 23 share a birthday:50.7297%See results ↓

Size of the group

365 equally likely days, a calendar with 29 February (one day in 1,461), or your own number of values

How many people are needed for this chance of a match?

Your Results

Chance at least two of 23 share a birthday: 50.7297%

Chance at least two of 23 share a birthday

50.7297%

Everyone different: 49.2703%

People needed for 50%

23

Pairs in the group

253

n(n − 1)/2: why matches come so soon

Expected matching pairs

0.6932

pairs ÷ d

Quick approximation

50%

1 − e^(−n(n − 1)/2d)

In a group of 23, the chance that at least two share a birthday is 50.73%. You need 23 people for a 50% chance of a match among birthdays.

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

Chance of a shared value by group size

Chance of a shared value by group size

Detailed Breakdown

Group size needed for each chance of a match
Target chancePeople neededExact chance with that many
10%1011.695%
25%1525.29%
50% (your target)2350.73%
75%3275.335%
90%4190.315%
95%4795.477%
99%5799.012%
99.9%7099.916%

How This Calculator Works

How it's calculated

It is easier to work out the chance that nobody shares. The first person can have any of d days, the second any of the d − 1 others, the third d − 2, and so on, so the chance that all n are different is d/d × (d − 1)/d × … × (d − n + 1)/d. The chance of at least one match is 1 minus that.

P(all different) = ∏ (d − i)/d for i = 0 … 22, with d = 365
= 49.2703%, so P(at least one match) = 1 − 49.2703% = 50.7297%
Pairs: 23 × 22 ÷ 2 = 253; approximation 1 − e^(−pairs/d) = 50%

Frequently Asked Questions

How many people do you need for a 50% chance of a shared birthday?

Twenty-three. With 23 people the chance that at least two share a birthday is about 50.7%, assuming 365 equally likely birthdays. With 22 people it is about 47.6%, just under even odds.

Why is it called a paradox?

It is not a true paradox, just a surprising result. Most people compare the group size with 365 and guess that you need about 180 people. The surprise goes away once you count pairs: 23 people make 253 different pairs, and each pair has a 1 in 365 chance of matching.

What is the chance that someone shares my birthday?

That is a different, much smaller number, because only the pairs that include you count. With n − 1 other people it is 1 − (364/365)^(n − 1): about 5.9% in a group of 23, and you need 253 other people for a 50% chance.

How many people make a shared birthday almost certain?

With 57 people the chance passes 99%, and with 70 it is 99.9%. Only with 366 people (367 counting 29 February) is a match guaranteed, by the pigeonhole principle: there are more people than possible birthdays.

Does 29 February change the answer?

Very slightly. Choosing the calendar with 29 February treats it as one day in 1,461 (once every four years) and the other dates as 4 in 1,461. The extra possible day makes matches marginally less likely: 23 people give about 50.69% instead of 50.73%, and 23 is still the smallest group for a 50% chance.

Are real birthdays equally likely?

Not quite: in Canada and the United States more babies are born in late summer and early autumn, and fewer on holidays such as 25 December and 1 January. Uneven birthdays make matches slightly more likely, so the calculator’s figures are a small underestimate for real groups.

How does the birthday problem apply to hash collisions?

A hash function assigns each item one of d values, so the chance that two items get the same value follows the same formula. Choose "My own number of values" and enter d: for a 32-bit hash (4,294,967,296 values) a collision becomes more likely than not at about 77,000 items, roughly √d. This is the idea behind the "birthday attack" in cryptography.

What is the quick approximation?

For groups much smaller than d, P ≈ 1 − e^(−n(n − 1)/(2d)): the number of pairs divided by d, put through the exponential. It gives 50.0% for 23 people, close to the exact 50.7%, and is the basis of the rule of thumb that you need about 1.18√d items for even odds.

Assumes birthdays (or values) are independent and equally likely, apart from the optional 29 February weighting. Results are computed in double precision from the exact product (about 15 significant digits); very large groups use a series that is exact to that precision. Not included: the real-world unevenness of birthdays (more births in late summer and fewer on holidays), twins, the chance that three or more people share, near-matches within a few days, or matches with one particular person (that is 1 − (364/365)^(n − 1), much lower).

Birthday Paradox Calculator: Shared Birthday Odds and Hash Collisions

By FindMySum · Last reviewed

The birthday paradox is the surprising fact that in a group of just 23 people, the chance that at least two share a birthday is better than even. This calculator gives that probability for any group size, finds how many people you need for any chance of a match, and applies the same maths to anything with a fixed number of equally likely values, such as hash codes. It opens with the classic example: 23 people and a 50% target.

The formula

Counting matches directly is awkward, because a match could be between any two people, or several pairs at once. The opposite event is simple: everybody has a different birthday. Line the group up and give them birthdays one at a time:

  • the first person can have any of the 365 days;
  • the second must avoid one day, so has 364 of 365 choices;
  • the third must avoid two days: 363 of 365;
  • and so on, until person n, who has 365 − n + 1 of 365.

Since the birthdays are independent, the chance that all of them are different is the product:

P(all different) = 365/365 × 364/365 × 363/365 × … × (365 − n + 1)/365

and the chance of at least one shared birthday is:

P(shared) = 1 − P(all different)

With d possible values instead of 365, replace 365 by d. Once n is larger than d, a match is certain.

Worked example: 23 people

For 23 people the product has 23 factors, from 365/365 down to 343/365. Multiplying them gives about 0.4927, so the chance that everyone has a different birthday is 49.27%, and the chance of at least one shared birthday is 1 − 0.4927 = 50.73%. With 22 people the chance is 47.57%, so 23 is the smallest group for better than even odds. These are the calculator's opening figures.

The table under the calculator gives the group size for a range of targets: 10% needs 10 people, 25% needs 15, 50% needs 23, 75% needs 32, 90% needs 41, 95% needs 47, 99% needs 57 and 99.9% needs 70.

Why the answer is so small: count the pairs

The intuition that you need around 183 people comes from thinking about your own birthday. The question is about any two people, and a group of n people contains n(n − 1)/2 pairs. Twenty-three people make 253 pairs. Each pair matches with a chance of 1 in 365, so on average a group of 23 contains 253/365 ≈ 0.69 matching pairs, and the chance of at least one is about half.

This also gives a useful approximation. If each pair matched independently, the chance of no match would be (1 − 1/d)^pairs ≈ e^(−pairs/d), so:

P(shared) ≈ 1 − e^(−n(n − 1)/(2d))

For 23 people that gives 50.0%, very close to the exact 50.7%. Setting the approximation to 50% and solving gives n ≈ 1.18√d: about 22.5 for d = 365. The calculator shows both the exact figure and the approximation.

Matching your own birthday

A different question is the chance that someone shares your particular birthday. Only the n − 1 pairs that include you count, so the chance is 1 − (364/365)^(n − 1). In a group of 23 that is about 5.9%, and you would need 253 other people for a 50% chance. Confusing the two questions is the source of the paradox.

29 February

The calculator's second calendar treats 29 February as one day in four years. Over four years there are 1,461 days, so each ordinary date has a weight of 4/1,461 and 29 February a weight of 1/1,461. The probability that everyone has a different birthday then has two parts: nobody born on 29 February, or exactly one person born on it (two people on 29 February would be a match). The effect is tiny: 23 people give 50.69% instead of 50.73%.

Real birthdays are not uniform

The formula assumes all days are equally likely. Real birth dates are not: in Canada and the United States there are more births in late summer and early autumn, and fewer on public holidays and, since planned deliveries became common, on weekends. Any unevenness makes matches more likely, not less, so the uniform figure is a slight underestimate. For everyday groups the difference is small.

Hash collisions and other uses

The same maths applies whenever items are assigned one of d values at random. Choose "My own number of values" and enter d:

  • Hash functions. A 32-bit hash has 4,294,967,296 possible values. A collision becomes more likely than not at 77,164 items, close to the approximation 1.18 × √(2^32) ≈ 77,000. This is why cryptographers say an n-bit hash offers only n/2 bits of collision resistance.
  • Random IDs. If a system gives users random six-digit codes (1,000,000 values), two users are likely to share a code after about 1,178 sign-ups.
  • Lottery and raffle numbers, birth months (d = 12: five people give a 61.8% chance of a shared month), or anything else drawn from a fixed set.

For very large d and n the calculator switches to a series expansion of the logarithm of the product, which keeps the result accurate to about 15 significant digits.

Assumptions

The calculation assumes values are independent and equally likely (except for the 29 February weighting), and it counts a match of two or more. It does not cover three-way matches, near-matches such as birthdays within a week of each other, or groups with related people such as twins.

More questions

In a classroom of 30, how likely is a shared birthday?

About 70.6%, assuming 365 equally likely birthdays. Teachers often run this as a class experiment: with 30 students a match turns up in roughly seven classes out of ten. With a group of 40, such as two classes together, it rises to about 89.1%.

What is the chance that three people share a birthday?

Much lower than for two. A triple match needs about 88 people before it becomes more likely than not, compared with 23 for a pair. The calculator covers pairs only; triples need a more involved count of the ways people can be grouped.

Do two people on a soccer pitch share a birthday?

A soccer match has 23 people on the field when you count the referee (two teams of 11), which is exactly the group size that gives a 50.7% chance. Studies of World Cup squads, which have 23 players each, have found about half of the squads contain a shared birthday, as the maths predicts.

Why does the chance grow so fast with group size?

Because the number of pairs grows with the square of the group size. Ten people make 45 pairs, 23 make 253 and 50 make 1,225. Each new person can match everyone already in the room, so the chance of no match falls faster and faster.

Is the birthday paradox used in computer security?

Yes. A birthday attack looks for any two inputs that give the same hash output, rather than a match with one particular hash. Because of the birthday effect, finding a collision in an n-bit hash takes about 2^(n/2) attempts instead of 2^n, which is why secure hashes such as SHA-256 have long outputs.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy