1. What is the probability that at least two people in a group of 30 have the same birthday?

2. How large would the group have to be for the odds to be about even?

This classic puzle requires a little knowledge of probability math and a good calculator to do.

### Solutions to Birthdays puzzle

2. 23 people

The solution uses an indirect approach: The probability P that at least two in a class of 30 have the same birthday will be 1 minus the probability that no two have the same birthday. So first you need to determine the probability that no two will have the same birthday in a group of 30:

The probability that both people in a group of just two will have the same birthday is 1/365 because there are 365 possible birthdays (disregarding leap years). Therefore the probability that both won't have the same birthday is 1 minus 1/365 or 364/365. In other words, if one person has a birthday on a certain day, that leaves 364 chances out of 365 that the second person's birthday will be different.

If you add a third person to the group, two days are already used up by the first two, which leaves 363 possible birthdays. So the probability that the first two don't have the same birthday and that the third person has a birthday different from both can be found by using the multiplication rule, and the probability of none of the three having the same birthday is

(364/365) (363/365).

The same logic continues on for however many people are added to the group. For a group of 30, if no two have the same birthday, then all 30 have different birthdays. The probability of this occurring is

(365/365) (364/365) (363/365) (362/365) . . . (336/365)

Therefore the probability P of this not occurring — that is, of at least two people having the same birthday — is 1 minus that amount or

1. P = 1 - (365/365) (364/365) (363/365) (362/365) . . . (336/365)
2. which simplifies to P = 1 - (365!/335!)/(36530)
3. which further simplifies to P = 365!/(335!*36530)

This is fine, but actually calculating such a number is a problem, since 365! (and even 335!) are truly huge numbers and well beyond the computing capability of the usual calculator, or even of the typical home computer not having special software installed.

But the calculations can be set up in such a way that each division operation can be done as it occurs, rather than trying to compute 365! all at once. In other words, use the formula in line (1) above rather than the one in line (3).

The following program can be entered on a TI-83+ calculator and run.

```			:While 1
:Input "NUMBER IN GROUP ",N
:1->P
:365->F
:While F>365-N
:P*F/365->P
:F-1->F
:End
:Disp 1-P
:End
```

Using this program, a table of probabilities for two or more people in groups of 1 to 60 having the same birthday can be created, as below. (Those for 23 and 30 people are marked in red.)

 1 0 16 0.2836 31 0.7305 46 0.9483 2 0.0027 17 0.315 32 0.7533 47 0.9448 3 0.0082 18 0.3469 33 0.775 48 0.9606 4 0.0164 19 0.3791 34 0.7953 49 0.9658 5 0.0271 20 0.4114 35 0.8144 50 0.9704 6 0.0405 21 0.4437 36 0.8322 51 0.9744 7 0.0562 22 0.4757 37 0.8487 52 0.978 8 0.0743 23 0.5073 38 0.8641 53 0.9811 9 0.0946 24 0.5384 39 0.8783 54 0.9839 10 0.1169 25 0.5687 40 0.8912 55 0.9863 11 0.1411 26 0.5982 41 0.9032 56 0.9883 12 0.167 27 0.6269 42 0.914 57 0.9901 13 0.1944 28 0.6545 43 0.9239 58 0.9917 14 0.2231 29 0.681 44 0.9329 59 0.993 15 0.2529 30 0.7063 45 0.941 60 0.9941

Which can be graphed: ### Recursive method

You can get the same results using a recursive function.

P = 1 - (364/365)*(363/365)*(362/365)*(361/365)*. . . *(336/365)

In the sequential mode on the TI=83+ Graphing Calculator, enter

u(n)=u(n-1)((366-n)/365),

where n is the group size, which starts at 1. The starting value u(n) is also 1.

Then simultaneously define v(n)

v(n)=1- u(n -1)((366- n)/365)

and have it start at 1 also. (Using simply v(n)=1-u(n) gives a domain error, so you have to write it out.)

In WINDOW, set the domain from 1 to whatever maximum group size you want, e.g., 60. Set the range from 0 to 1.

This will plot both graphs, u(n) and v(n), where u(n) is the probability that no two people in a group of n people have the same birthday, and v(n) is the probability that at least two people in a group do have the same birthday. The graphs cross at n =23, which is the break even point. All the numbers are correct.

It has to be done with two separate functions because the "1 -" part must not be recursed.

Also, you need to have "366- n " rather than "365- n " in both function definitions in order to make the resulting probability figures correspond to the appropriate group size.

Note: You can, if you want, de-activate the u(n) graph and show only the v(n) graph by placing the cursor on the first u(n) highlighted equal sign and pressing ENTER. This will make the highlighting for u(n) go away and cause only the v(n) graph to be displayed, which is the same as the graph pictured above.