[WARNING: Spoilers are all over this story.]

By Monday night’s episode, James Holzhauer had been on a weeks-long path to beat the record for “Jeopardy!” champion winnings. Then he appeared to make a shockingly small Final Jeopardy wager.

Even Alex Trebek seemed surprised.

“A modest one, for the first time,” Trebek mused.

It was that comment that led viewers to speculate Holzhauer bet too low — at $1,399 — with the intention of losing.

There were a couple of reasons to think it might have been the case: Maybe he wanted to leave Ken Jennings’s standing record intact? (Highly unlikely.) Or, perhaps he did it for his daughter. Holzhauer has recently spoken about how his “Jeopardy!” run affected the 4-year-old. At first, she would cry because she did not want her dad to lose. To calm her, Holzhauer said he promised her they would throw a big party when he lost, to celebrate his long run.

After that, she would cry when he won. She really wanted to have that party.

It is an adorable anecdote, but a breakdown of the math shows $1,399 was the smartest bet the professional sports gambler could have made.

“It was absolutely the right wager,” said Brad Rutter, the all-time leader in “Jeopardy!” earnings.

Rutter told The Washington Post that Holzhauer’s bet “was 100 percent his best chance at winning.”

Going into Final Jeopardy, Holzhauer had $23,400, trailing behind Emma Boettcher, who was leading with $26,600. Jay Sexton held third with $11,000.

The only way Holzhauer could have won was if Boettcher guessed wrong while he answered correctly, according to Rutter. In this scenario, Boettcher, who wagered $20,201, would have been left with $6,399. Holzhauer would have won with $24,799.

But in yet another alternate universe, Sexton could have won if Holzhauer and Boettcher both answered incorrectly while the Sexton answered correctly. To safeguard against coming in third, Holzhauer had to ensure he had more than Sexton’s maximum amount of money, which was $22,000, according to Rutter.

Holzhauer’s wager, had he answered incorrectly, would have left him with $22,001.

Assuming Boettcher guessed correctly, even if Holzhauer had bet everything he had, she still would have beaten him, according to Rutter. “He bet as much as he could” to win, he said.

In an interview with the Action Network, Holzhauer confirmed the strategy.

“I knew I could only win if Emma missed Final Jeopardy, as there was no way she wouldn’t bet to cover my all-in bet,” Holzhauer said. “So my only concern was getting overtaken by third place, and I bet just enough to make sure of locking him out. Betting big would have looked good for the cameras, but now I turn my straight bet (Emma misses) into a parlay (Emma misses, and I get it right).”

Holzhauer became famous as he trounced more than 60 contestants with his seemingly endless trivia knowledge and fast-paced betting style. Rutter said Holzhauer’s final bid was in character with the type of player he was.

“The idea that he would make a mistake or lose on purpose,” Rutter said. “Those are the two least likeliest things he would do.”

Read more:

James Holzhauer was on pace to break a ‘Jeopardy’ record today. Then this happened.

‘Jeopardy’ winner James Holzhauer keeps dominating. Does it matter if he broke the game?

What it’s like to lose to unstoppable ‘Jeopardy!’ champion James Holzhauer

The children’s books that turned James Holzhauer into a ‘Jeopardy!’ champ

Opinion: Ken Jennings: Why I’m rooting for James Holzhauer on ‘Jeopardy!’