Mathematicians at the University of Manchester in the United Kingdom have worked out how many lottery tickets you need to buy to guarantee yourself a win.

Even if you follow their advice to a tee, however, you'll probably end up losing money. That's the discouraging reality of playing a game of chance designed to favor the house.

In the UK's National Lottery game, 'Lotto', players buy a ticket with six numbers. They win if at least two of their ticket's numbers match the six numbers between 1 and 59 that are randomly chosen that day.

Two number matches gets you a free entry to the next game. Three matches gets you £25; four matches around £100; five matches around £1,000; and a six-match 'jackpot' between £2 to £4 million depending on the day.

Each ticket costs £2.

To figure out the minimum number of tickets you would need to buy to guarantee yourself at least a two-match win, researchers used a system of finite geometry based on a Fano plane.

This is a triangle with seven lines and seven points, where each line includes three points and each point connects to three lines.

If each point represents two numbers, each line represents a ticket with six numbers.

To cover all the possibilities of a six-number lottery draw, researchers needed three Fano planes and two simple triangles. Counting up all the lines gives you 27 tickets, which would cost £54 in total.

According to the mathematicians, David Stewart and David Cushing, if you choose tickets in this way, then no matter which of the 45,057,474 possible draws occurs, you'll have at least one ticket that wins at the lowest level.

Practically, you can test this by comping up with a random six-number series and seeing that at least two of these numbers must show up on at least one of these Fano triangles.

For instance, if the lotto draw is "12, 22, 32, 42, 52, and 1", two of these numbers show up on the right triangle in the middle row in the image above.

Whereas, if the lotto draw is "52, 33, 1, 11, 5, and 50", two of these numbers show up on the left triangle in the first row.

If you buy just 26 tickets, it's possible to find a six-number series that doesn't hit two numbers on a Fano plane. But even if you buy 27 tickets and guarantee yourself a win, Stewart and Cushing warn that you have only a one percent chance of making your £54 back.

When these two mathematicians tested their idea on a Lotto held in July of 2023, they only had three tickets that matched two of the numbers drawn that day, making them zero money in the end.

If nothing else, their work provides a cautionary tale: winning the lottery isn't always worth it.