The odds of striking it rich in the lottery are remarkably small, but apparently it really helps if you’re a math genius.

Several years ago, a group of students from the famed Massachusetts Institute of Technology cracked the lottery code that enabled them to win millions of dollars — and state officials did nothing to stop it.

A recent report by the Massachusetts inspector general revealed that the MIT students figured out a way to predict success in the state’s lottery, and they were so good at it that by 2005, they’d racked up almost $8 million in prize money.

What was their secret? According to the New York Daily News:

The math whizzes quickly discovered that buying about $100,000 in Cash WinFall tickets on those days would virtually guarantee success. Buying $600,000 worth of tickets would bring a 15%–20% return on investment

Seems the Massachusetts Lottery knew what was going on and even bent the rules to allow the group to buy hundreds of thousands of $2 tickets. So why didn’t officials do something? Because all those extra ticket purchases increased revenues and made the lottery more successful.

The students didn’t break any laws, but state treasurer Steven Grossman, who oversees the lottery, finally put the kibosh on the game this year. And since lottery officials didn’t personally gain anything from turning a blind eye, the inspector general said they wouldn’t be punished either.

It’s not the first time students from MIT have cashed in on their super-powers — a group of blackjack card counters from the school inspired the book ‘Bringing Down the House’ and the movie ’21.’

[Time]