(Update: If you thought this story was something, check out the Stanford PhD who reportedly gamed the Texas lottery and walked away with $20 million.)

The lottery is usually a lousy return--but for a husband and wife team who figured out a math error in games run by two states, it became a wildly profitable investment strategy.

Meet Marge and Jerry Selbee, owners of a "party store" in Evart, Michigan that sold cigarettes, liquor, and lottery tickets. After watching thousands of customers, Jerry figured out how to hack the odds in a certain type of lottery: called Winfall in Michigan, and later Cash WinFall in Massachusetts.

Play a dollar here and there, and you might win occasionally. But play thousands and thousands in particular weeks, when the prize accumulated in a certain way, and Jerry realized you could almost guarantee a profit to the tune of five or six figures.

So that's what the Selbees started doing, to the point that playing the lottery became a full-time job at times. Over the course of nine years, it worked, to the point that their estimated total lottery haul was almost $27 million.

The work

The math is explained at greater length in a recent, 10,000-word article on The Huffington Post (which I highly recommend). But the really hard part, once the Selbees figured it out, was simply the process of actually buying and examining thousands of lottery tickets.

This required physically going to stores in person, standing in front of machines for hours, buying the tickets, and printing them out.

Selbee started on his own in 2003, spending a few thousand dollars a week, while keeping the whole thing a secret from his more risk-averse wife.

After two weeks of betting, during which he made $6,300 after buying $3,400 worth of tickets--and then grossed $15,700 after buying $8,000 worth of tickets, he came clean.

She bought in.

"Oh, I knew it would work," Marge said later, given her husband's propensity for code-breaking and math. "I knew it would work."

The MIT gang

After first few hundred thousand dollars in profit, the Selbees started a company to fund and organize the whole thing.

Then, Michigan closed down the game they were playing, and they focused on Massachusetts, where the stakes were higher. This also required a 12-hour drive each way to play--standing in convenience stores, for days at a time.

The Selbees took on investors, and then faced another challenge: a group of students from MIT who had also figured out the odds, formed an organization, attracted investors, and started making millions.

Like big bettors at the racetrack or in Las Vegas, each big group started to interfere with the other's strategy.

But in the end, it was the Boston Globe newspaper that brought the whole thing crashing down.

The investigators

There was nothing illegal about what the Selbees or the MIT group were doing, but there was a perception that they were juicing the odds in their favor--and away from the "little guy" player, who might picking up a couple of lottery tickets on the way home from work.

It didn't matter, as the Selbees would later argue, that their out-of-state money was pumping millions of dollars into the Massachusetts lottery's coffers--and was ultimately distributed to the state's cities, towns, and schools.

It just didn't look right.

And, there was also the fact that lottery officials in Massachusetts had started to figure out that the Selbees and the MIT students had identified an advantage, but had done very little to combat it.

"How do I become a member of the [Selbees'] club when I retire?" one lottery official joked in an email that later became public.

The Boston Globe stories, written by the same Spotlight team that had exposed child sexual abuse in the Catholic church (and served as the basis for an Oscar-winning movie)--foretold the end of the story.

The Massachusetts Lottery shut down the game. And the Selbees made their final trip back to Michigan, after their 55th week of playing.

Still: $27 million gross

They'd been vilified in the media, Jerry Selbee felt, even after he'd sat for interviews himself with the Globe reporter. Still, he seemed to think, it was a small price to pay--and well worth the cost.

The Selbees "grossed nearly $27 million" all together, netting $7.75 million, according to the Huffington Post report, which culminates with a more recent interview with the couple.

Besides, they're back in Michigan now--hundreds of miles away from the Massachusetts media. And they doubted too many people would have given up the opportunity they'd taken, if they knew it existed.