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

  1. About 70.63%
  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.)

10.0000160.2836310.7305460.9483
20.0027170.3150320.7533470.9448
30.0082180.3469330.7750480.9606
40.0164190.3791340.7953490.9658
50.0271200.4114350.8144500.9704
60.0405210.4437360.8322510.9744
70.0562220.4757370.8487520.9780
80.0743230.5073380.8641530.9811
90.0946240.5384390.8783540.9839
100.1169250.5687400.8912550.9863
110.1411260.5982410.9032560.9883
120.1670270.6269420.9140570.9901
130.1944280.6545430.9239580.9917
140.2231290.6810440.9329590.9930
150.2529300.7063450.9410600.9941

Which can be graphed:





Recursive method

You can get the same results using a recursive function.

Again, start with the indirect algorithm above:

 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.