The Birthday Problem

Dr. Math FAQ || Classic Problems || Formulas || Search Dr. Math || Dr. Math Home

 Suppose you flip a coin and bet that it will come up tails. Since you are equally likely to get heads or tails, the probability of tails is 50%. This means that if you try this bet often, you should win about half the time. What if somebody offered to bet that at least two people in your math class had the same birthday? Would you take the bet?

This question is more complicated than flipping a coin, because the chance of finding two people with the same birthday depends on the number of people you ask. If there were only one other person in your math class, you might be surprised to find out that she had the same birthday as you. If there were a pair of people with the same birthday in a class of 366 people, would you still be surprised?

How large must a class be to make the probability of finding two people with the same birthday at least 50%?

Let's forget about leap year when we solve this problem (no February 29 birthdays!) This way, we can assume that a year is always 365 days long.

Also, let's assume that a person has an equal chance of being born on any day of the year, even though some birthdays may be slightly more likely than others. That will simpify the math, without changing the result signficantly.

We'll start by figuring out the probability that two people have the same birthday.

The first person can have any birthday. That gives him 365 possible birthdays out of 365 days, so the probability of the first person having the "right" birthday is 365/365, or 100%.

The chance that the second person has the same birthday is 1/365. To find the probability that both people have this birthday, we have to multiply their separate probabilities. (365/365) * (1/365) = 1/365, or about 0.27%.

The chance of the first and second person sharing a birthday is still 1/365. The first and third person might share a birthday instead. The probability of that is 1/365 as well. But what if the second and third person shared a birthday? And what if all three of them had the same birthday?

Things are getting complicated fast. Four or five people would be even messier. Is there a simpler way?

To solve the birthday problem, we need to use one of the basic rules of probability: the sum of the probability that an event will happen and the probability that the event won't happen is always 1. (In other words, the chance that anything might or might not happen is always 100%.) If we can work out the probability that no two people will have the same birthday, we can use this rule to find the probability that two people will share a birthday:

P(event happens) + P(event doesn't happen) = 1
P(two people share birthday) + P(no two people share birthday) = 1
P(two people share birthday) = 1 - P(no two people share birthday).

So, what is the probability that no two people will share a birthday?

Again, the first person can have any birthday. The second person's birthday has to be different. There are 364 different days to choose from, so the chance that two people have different birthdays is 364/365. That leaves 363 birthdays out of 365 open for the third person.

To find the probability that both the second person and the third person will have different birthdays, we have to multiply:

(365/365) * (364/365) * (363/365) = 132 132/133 225,

If we want to know the probability that four people will all have different birthdays, we multiply again:

(364/365) * (363/365) * (362/365) = 47 831 784/ 48 627 125,

We can keep on going the same way as long as we want. A formula for the probability that n people have different birthdays is

((365-1)/365) * ((365-2)/365) * ((365-3)/365) * . . . * ((365-n+1)/365).

If you know permutation notation, you can write this formula as

(365_P_n)/(365^n).

That's the same as

365! / ((365-n)! * 365^n).

We've made some progress, but we still haven't answered the original question: how large must a class be to make the probability of finding two people with the same birthday at least 50%?

We know that the probability of finding at least two people with the same birthday is 1 minus the probability that everybody has a different birthday, and we know how to find the probability that everybody has a different birthday for any number of people. The easiest way to find the right class size is to use a calculator to try different numbers in the formula. It turns out that the smallest class where the chance of finding two people with the same birthday is more than 50% is... a class of 23 people. (The probability is about 50.73%.)

- Ursula Whitcher, for the Math Forum