**Puzzle**
In the Massachusetts Megabucks lottery, six different numbers from 1 to 42 (inclusive) are selected. When you buy a ticket, you can ask for a "quick pick" in which the computer chooses the numbers for you, and you can purchase up to five games on a single ticket. We'll assume that the computer's random number generator is fair, giving each possible combination an equal probability of being chosen.

1. If I "quick pick" for two games, what are the chances that the two games have the same combination of numbers?

2. If I "quick pick" for five games (one five-game ticket), what are the chances that there are two games on that ticket with the same combination?

3 (The toughie). How many five-game quick-pick tickets would I have to buy in order to have a greater than 50% chance of having at least one ticket with two games on it that match exactly?

**Solution**
1. 1/5245786. The first game on the ticket will be some combination. Then you just calculate the chances that the second game on the ticket will match it. This number of combinations is (42 choose 6) or

42! / 6! (42-6)! = 5245786

So the chances that they match is 1 over this number.

2. For this sort of problem, where you are asking what are the chances of something happening at least once out of several opportunities to happen, you first calculate the opposite -- the chances of it NOT happening in all the tries -- and subtract from 1. So, what are the chances that the 5 games on the ticket are all different?

We know that there are 5245786 possibilities for any one game. In the first game, we choose one of them. The second game now has a 5245785 / 5245786 chance of being different from that first one. Now the third game has a 5245784 / 5245786 chance of being different from either of the first two; and the fourth has a 5245783 / 5245786 chance of being a new selection. When you have the chances of individual events occurring, and you want to know the chance of them ALL occurring, you just multiply. We multiply the chances of all these events occurring (that is, each choice being different) to get:

(5245785 * 5245784 * 5245783 * 5245782) / 5245786 ^ 4

This equals

0.99999809370925005714289758986902

Remember, this is the chance of all of the games on a five-game ticket being different. So the chance of at least two of them being the same is 1 minus this number, or

0.0000019062907499428571024101309848736

which is a really tiny number.

3. We take a similar approach with this calculation that we took before: figure out the chance of it not happening for N tickets, and subtract that value from 1. Then we set that chance to 0.5 and solve for N.

We already know the chance of it happening in one try: the tiny number above, which, for now, we'll call p. So the chance of it NOT happening in one try is (1-p). The chance of it NOT happening in n tries is (1-p)^n, so the chance of it happening at least once in n tries is [1 - (1-p)^n]. We set this formula to 0.5 and solve for n.

Of course, solving for n is tricky, unless you are comfortable with logarithms. I start with the equation

0.5 = [1 - (1-p)^n]

Simplify

0.5 = (1-p)^n

Take natural logarithm of both sides

ln(0.5) = ln( (1-p)^n)

Use logarithm magic

ln(0.5) = n * ln(1-p)

Divide both sides by ln(1-p)

n = ln(0.5) / ln(1-p)

Plug in the number (which we already know) for p and let the calculator do what it's good at

n = 363610.07359999192796640483226154

which is how many tickets we would have to buy to have a 50% chance of seeing one ticket with a match. Since we can't buy fractional tickets, we round up, to make sure we have a greater than 50% chance.

So we need to buy 363611 five-game tickets to have a better than 50% chance of having at least one ticket on which two games match exactly.