Ask a sharp advantage player what he thinks of the lottery and said AP will most likely laugh in your face. You don’t need to be James Grosjean to know that the lottery is strictly for suckers, dreamers and grandmothers. After all, the odds of winning the grand prize looms at around 1 in 292-million. To put things into perspective, the likelihood of being struck by lightning over the course of your lifetime: 1 in 3,000. Fortunately, nobody shared any of this information with Stefan Mandel. Otherwise, he might not have gone on to become the world’s winningest lottery player.

Relying on skill rather than luck, Mandel has taken down 14 lotteries, in at least three countries, and raked in some $40-million. But, like every good AP, he tries to downplay his brilliance. “I’m a weekend mathematician,” he insisted to the Romanian magazine Night & Day. “[I’m] an accountant with too much education. But, mathematics, applied properly, can guarantee a fortune.”

It probably helped that he was living in Romania, in 1964, when the country was under communist rule. At the time, he was toiling as a numbers-cruncher for the national mining company and seeking a score that would lead to a more comfortable life. Maybe it would even get him out of Romania – which, back then, was not the greatest place for brainy Jews.

For some reason, Mandel began to focus on the state lottery. He took it apart, dissected it, looked for edges in the same way that Edward O. Thorp was attacking the seemingly unbeatable game of blackjack. Unlike Thorp, though, Mandel did not have the benefit of a university’s room-sized computer. He simply had his brain, intellectual ambition and a desire to change his life. 

During off hours, he immersed himself in mathematical concepts and theories. He came up with a theorem that he called Combinatorial Condensation. It was an algorithm that allowed him to guarantee a second place finish in a six-number lottery. Essentially, by picking five out of the six numbers and buying all the tickets with the corresponding combinations, he could 100-percent realize a second-place finish, which was good enough for him. 

With the financial backing of friends who believed in Mandel’s beautiful mind, he procured the tickets and did better than expected. Getting a little lucky, Mandel and his investors took the first-place prize. That brought them $30,000 worth of Romanian leu. After paying taxes and shipping money to his investors, Mandel was left with $5,000 in leu, which came to about $40,000 in today’s valuation. 

This windfall may not sound like a fortune, but it equaled eight years of salary for an average Romanian at the time. The sum was enough for Mandel to finagle his way out of his homeland. He spent the next few years roaming around Europe – and we wouldn’t be surprised if he applied his mathematical smarts to casino games around the continent – before settling in Israel. Once there, Mandel attended university in Haifa and earned a degree in economics. 

By the 1980s, Mandel had made his way to Australia. He worked as an accountant, invested in precious metals and lived a life of domesticity. While he never forgot about the lottery, the prospect of winning a drawing with 45 numbers and more than 8-million combinations must have seemed like an impossibility – even to Mandel. 

So he hit the books and came up with another algorithm. This one allowed Mandel to reduce the number of needed tickets from 8-million to 3-million. It was more complicated, more profitable and more of a secret (Mandel never released details on phase II of his lottery-beating strategy). It also seemed unbelievable. 

But, of course, armed with the uncontestable reality of math, Mandel knew better. “Not all lotteries are profitable from the player’s point of view,” he has said. “The only sure way to win is to cover all the possibilities. The one in Sydney provided the opportunity for me to invest $7-million in order to win $27-million.”

With that kind of clear-headed thinking, Mandel managed to find investors for his scheme. And technology made the process easier than it would have otherwise been. By now it was 1987 and personal computers were easily accessible. He used them to work out the details and to print the millions of forms required to purchase the necessary tickets.

“When I announced [in 1987] that I would take the big prize in the Sydney lottery, everyone told me, ‘You won’t succeed,’” Mandel said. “I got angry and won the big prize 13 times in a row, with $400,000 in smaller prizes.”

Australian authorities got angry as well – and changed lottery laws to make it impossible for Mandel to keep beating the game. Undaunted, he set his sites on America. More specifically, he focused on the Virginia lottery. The appeal for him, according to Washington Post, is that “Virginia boasted fewer number combinations than other lotteries … Mandel concluded it would cost only $7.1-million to buy every ticket” – which could be printed out at home in Australia, as per the Virginia lottery’s regulations.

But the prize-money had to be big enough to make the investment worthwhile. So Mandel waited patiently and monitored the pools. As soon as one hit $27-million, Mandel pulled the trigger and put his plan into motion – with just three days in which to buy some 7-million tickets. 

Thirty computers and a dozen laser printers were put to work. Mandel told “How’d They Do It” that he used “20 or 30 tons of paper” in order to create all the tickets. Then he invested $60,000 on having them jetted from Australia to the United States. A team of accountants came on board to ferry the tickets to lottery outlets and pay for the tickets that had already been printed. 

It went off without a hitch – until Mandel and his team ran out of time, managing to buy only some 5-million tickets at the time of the drawing. Though the Virginia lottery had ceased to be a lock, Mandel was still a favorite and things fell in the way they were supposed to. He and his crew won the first prize along with a million-dollars or so in smaller prizes. 

The deal was good for Mandel – he paid himself a $1.7-million fee for organizing everything – though the investors did less well: those who put in $4,000 wound up with only $1,400 after expenses and taxes. The US government inspected Mandel, and the Virginia Lottery Commission attempted to get out of paying him. Once it became clear that he did nothing wrong, though, the authorities had no choice but to make good on the money. That said, the rules have changed so that a Mandel-style gambit could never again be engineered.

Backed off from the most lucrative lotteries, Mandel tried creating one of his own (and failed) before doing some jail time in Israel due to a conviction for fraudulent activity. These days, once again a free man, the lottery king is said to be living a quiet life on a small island in the South Pacific. Just don’t expect him to try his luck on a random scratch-off. “I don’t like chance,” Mandel said “I consider it a discontinuity in social organization.”

Michael Kaplan is a journalist based in New York City. He has written extensively on gambling for publications such as Wired, Playboy, Cigar Aficionado, New York Post and New York Times. He is the author of four books including Aces and Kings: Inside Stories and Million-Dollar Strategies from Poker’s Greatest Players.

He’s been known to do a bit of gambling when the timing seems right.