Some lotto math

I planned to talk about this post from Mathew Ingram, but things went in a different direction, and I learned something new.

The story is about a couple who recently won their second lottery prize of over £1 million. They won the EuroMillions Millionaire Maker back in 2018 and just won the UK National Lottery’s Lotto in November. According to the National Lottery operators, the odds of this are over 24 trillion to one. I was certain that this calculation had been done by multiplying the probabilities of each lottery win, and I meant to throw a little cold water on that.

First, that calculation would apply only if they played each lottery once, which I thought extremely unlikely. Also, it would apply only before their first win; after the first win, their odds of getting the second one are the same as anyone else’s.

I wanted to include the odds of both games and show the calculation, but I was derailed. According to this page, the odds of the EuroMillions game “depend on how many prizes are offered and how many tickets are sold, so they are always different.” Then I saw this page with a table of odds for the UK Lotto game and realized that I didn’t know how to reproduce it. That was kind of embarrassing, so I decided to dig in and force you to dig with me.

Here are the rules of the UK Lotto game: There are 59 balls, numbered 1–59. Six of these balls are chosen in a drawing. Players choose six numbers and win if two, three, four, five, or six of their numbers match the drawn balls.1 The winnings go up with more matches. It’s the same as the New York Lotto except that New York’s game doesn’t give out money for only two matches.

Six matches

The probability of matching all six balls was the one calculation I could do immediately. The number of ways to choose 6 items from a pool of 59 is

C659=(596)=59!6!53!=45,057,474

This is the number of combinations. It’s equal to the binomial coefficient, and there are different notations for it. I’m going to use Ckn for the balance of this post.

Since there’s only one way to match all 6 balls, the probability is

145,057,4742.2194×108

Lotteries like to express probabilities as “1 in n,” so this appears as “1 in 45,057,474” in the table.

Five matches

This is where I started having trouble. The probability of getting 5 matches is not 1/C559. The lottery math page on Wikipedia gives the right formula,

P[5matches]=C56C153C659

but I didn’t think much of its explanation. Other explanations I found in combinatorics texts didn’t fit with my way of thinking, either, but after reading a few, I was able to put together an explanation that stuck:

Separate the 59 balls into two groups: the “good” group consists of the 6 balls selected in the drawing and the “bad” group consists of the 53 other balls. My ticket has 6 numbers on it, 5 of which are in the good group and 1 is in the bad group. (I’ve emphasized the and because we’ll return to it soon.) The number of ways of getting 5 items from a group of 6 is

C56=6

The number of ways of getting one item from a group of 53 is

C153=53

In set theory and probability, and implies multiplication, so there are

C56C153=653=318

ways to get exactly 5 matches on my ticket. Therefore, the probability of getting exactly 5 matches is

P[5matches]=31845,057,474=537,509,5797.0577×106

There is no way to further reduce the fraction in this formula, so a lottery would express this as “1 in 141,690.17” or maybe just “1 in 141,690.”

Four matches

Now that I understand the formula, I can apply it again and again. For exactly four matching numbers, the probability is

P[4matches]=C46C253C659=3,4457,509,5790.00045875

which can be expressed as “1 in 2,179.85” or “1 in 2,180.”

Three matches

Here, the probability is

P[3matches]=C36C353C659=234,26022,528,7370.010398

which can be expressed as “1 in 96.17” or “1 in 96,” although rounding to just two digits might be a little too much.

Two matches

This probability is

P[2matches]=C26C453C659=1,464,12515,019,1580.097484

which can be expressed as “1 in 10.26” or “1 in 10.3.”

The bonus ball

The values calculated above match the odds table for 6, 4, 3, and 2 matches, but not for 5 matches or “5 numbers + Bonus Ball.” What’s that about?

UK Lotto odds table

As mentioned in the footnote above, there’s an additional wrinkle to the game. After the six good balls are drawn, a seventh “bonus ball” is drawn from the remaining 53 balls. If five of the numbers on your ticket match five of the six good balls, you get a chance to match the bonus ball. If your bad number matches the bonus ball, that pushes you up into the “5 numbers + Bonus Ball” tier; if it doesn’t, you stay in the “5 numbers” tier.

So if you matched five of the original six numbers, the probability of your bad number matching the bonus ball is simply 1/53 and the overall probability of getting into this tier is

P[5matches+bonus]=537,509,579(153)=17,509,5791.3316×107

which is the “1 in 7,509,579” shown in the table.

Similarly, the probability of your one bad number not matching the bonus ball is 52/53, so the overall probability of being in the “5 numbers” tier is

P[5matchesonly]=537,509,579(5253)=527,509,5796.9245×106

which is “1 in 144,414.98” or “1 in 144,415,” as shown in the table.

Final comments

Although the number of combinations is always an integer, the “1 in n” odds presented by lotteries are often rounded to the nearest integer, at least if n is large. I’d never realized that before.

In Mathematica, the Binomial function is the way to calculate Ckn. In Python, it’s the comb function in the math library. Both of these can return values well beyond the limit of 64-bit integers.

Learning how lottery odds are calculated may not be the best way to stave off senility, but it beats doing crossword puzzles.


  1. There’s an additional wrinkle involving a “bonus ball,” but we’ll get to that later.