Forget Fermat’s last theorem. The most vexing challenge in mathematics just might be the Monty Hall problem. Monty Hall — born Monte Halparin — presented nearly 5,000 episodes of Let’s Make a Deal, the US game show that inspired the puzzle.

It is an onion of a conundrum; layer after layer, and guaranteed to make you cry. The puzzle is this: a contestant faces three doors. Behind one of them is a big prize such as a Cadillac. Each of the other two doors conceals a booby prize such as a goat.

The contestant chooses a door, hoping to win the grand prize. But just as the door is about to be opened, Hall steps in and halts proceedings. He opens one of the other two doors instead, revealing a goat. Then he turns to the contestant. Would they like to switch to the other closed door? Or would they prefer to stick with their original choice?

The problem was initially posed in The American Statistician in 1975, by Steve Selvin, but achieved national prominence when Marilyn vos Savant wrote about it in Parade in 1990. She suggested that it pays to switch doors. Her reward was a mailbag full of letters assuring her she was wrong — some from prominent mathematicians. John Kay’s inbox also overflowed when he addressed the problem in 2005 in the Financial Times.

What should the contestant do? Mathematically, it seems not to matter: there are two doors now, so surely they face a 50-50 proposition. And as it happens, many people prefer to stick. They have made their choice and would regret switching if it did not work out.

More careful analysis, however, reveals that the contestant should switch. One way to think of the problem is to notice that their chance of picking the grand prize was initially one in three.

Hall’s intervention does not change that, but it does guarantee that if they failed to pick the correct door initially then they will definitely get the prize by switching. Two times out of three, switching will win the prize.

A second way to think about the problem is to exaggerate the underlying process. Imagine 100 doors, but still only one grand prize. The contestant picks a door, probably not the correct one. Hall then opens 98 other doors, revealing no prize.

Should we really conclude that we have learnt nothing about the other door? The first door was picked at random but the one that Hall has left closed was selected with great care. With probability of 99 per cent, switching will win the prize.

A third way to attack the puzzle is to run an experiment. It will quickly reveal what intuition does not: the contestant should switch. In Ms vos Savant’s experience, many mathematicians changed their minds only on the basis of empirical evidence — which is revealing, since the underlying proof, using Bayes’ theorem, is not especially technical.

Some people will find these explanations persuasive, and others will not. Over the years I have concluded that there is something about the Monty Hall problem that makes it wonderfully resistant to our intuitions.

And there is a twist in the tale, too: after Ms vos Savant brought the problem to national attention, the journalist John Tierney visited Hall himself and they began to play the game repeatedly at his dining-room table, with car keys representing the grand prize and a pack of raisins serving as the goat. At first, things went as Mr Selvin and Ms vos Savant had explained: switching won the prize far more often.

Then, suddenly, things changed. At the beginning of a game, Mr Tierney pointed to one of the options. “Too bad,” said Hall, immediately. “You’ve just won a goat.”

He did not offer Mr Tierney a chance to switch. He did not always make such an offer in the game show — why should he make it now?

Hall’s change of approach turns a probability puzzle into what we might call a cheesecake bet. In the musical Guys and Dolls, Nathan Detroit offers Sky Masterson a bet that Mindy’s sells more strudel than cheesecake. Sky is sceptical, and rightly so, since Nathan already knows the answer. For much the same reason, a contestant in Let’s Make a Deal should ask themself: “If it is really such a good idea to switch, then why has Hall offered me the chance?”

I have great respect for the way Ms vos Savant faced down a posse of contemptuous mathematicians. But we must be careful not to confuse a precise mathematical description of a game for the vagaries of reality itself, something Nassim Nicholas Taleb has named the “ludic fallacy”. Rigorous mathematical thinking can be invaluable, or it can leave you blinkered and on the wrong side of a cheesecake bet.

The solution to the formal Monty Hall problem is counterintuitive and incontrovertible. But the right approach in the game show depended on what Hall himself was trying to do in offering the choice. Was he benevolent, malevolent, or simply aiming for great television?

Alas, we can no longer ask him. Hall died in September. But the Monty Hall problem will live on.

*Written for and first published in the Financial Times on 6 October 2017.*

*My new book is “Fifty Inventions That Shaped The Modern Economy”. Grab yourself a copy in the US or in the UK (slightly different title) or through your local bookshop.*