The Powerball jackpot currently sits at \$478 million, in spitting distance of January’s record-breaking \$1.5 billion jackpot, which dwarfed the MegaMillions \$656 million high-water mark of 2012. If another week goes by, we there’s a good chance we’ll have a new record.

Unless you’re really, really smart and lucky—see Joan Ginther, among others—playing the lottery is a bad idea, financially speaking. Of course there’s the fun, thrilling aspect of playing, which is not to be discounted, even by a belt-and-suspenders-type publication like MONEY.

But there’s actually a case to be made that in some rare instances, it’s mathematically advantageous to roll the dice on some Powerball, or other lottery tickets. When a jackpot grows, it brings up the value of a ticket, which in Powerball’s case costs \$2. That’s called the expected value, and it’s found by multiplying the payout by the probability of winning.

Here’s a simple example: In a basic lottery with just one prize, \$1 tickets, and 100 people playing, any jackpot over \$100 will mean that a ticket will be worth more than the \$1 it costs. If you bought all the tickets for \$100, you would win the jackpot and take home more than what you paid. So theoretically, at a certain size, a lottery ticket can actually be worth more than what you pay for it.

Read next: The Powerball Jackpot Is Up to Nearly Half a Billion Dollars

Still, if a jackpot is huge and a \$2 ticket somehow gets to be theoretically worth \$2.02, you’d have to buy a very large amount of tickets to see returns, similar to how the very slight odds a casino make it money over time. For fun, let’s see how high a jackpot would have to be to make mathematical sense to play.

First of all, there are three major things winners have to contend with—taxes, the lump sum discount, and potentially splitting the pot with other people.

### The simple version

There are other prizes besides the jackpot, but for simplicity’s sake, just to get a ballpark figure, we can discount them because they’re pretty insignificant. To find out how big a jackpot you’d need to get the value of a ticket to be equal or greater to than what you paid, you just divide the cost by the probability, which you can calculate by dividing one (1) by the odds. (That’s 1/292,201,338 in this case.) That equals around \$584 million. And that’s what the take-home sum needs to be to make it worthwhile to play.

If we add what would be taken out in federal income taxes (39.4%)—this exercise assumes you live in New Hampshire and don’t pay state income taxe—by dividing by 0.606 (1-0.394), we get \$974 million as the necessary pre-tax sum for the jackpot.

But then we have to contend with the possibility of multiple winners with and a split pot, which gets more and more likely as more tickets get sold. DurangoBill.com has a great chart that works those probabilities out, and if 500 million tickets are sold (this is conservative at this jackpot size, probably*), a jackpot’s value goes down about 37% when you account for the possibility of multiple winners. So \$974 million divided by 0.63 (1-0.37) comes to… a lump sum pre-tax cash payout of \$1.5 billion or a total jackpot of \$2.6 billion. This is the ballpark we’re working with.

### The complicated version

But the “break even” jackpot is actually a little lower! There are, after all, plenty of other prizes at stake. To adjust for those, it’s helpful to find out how much they’re worth, again by finding their expected value.

Adding up the expected values for all those prizes absenting the jackpot comes to \$0.24 (for each prize: Prize x probability+prize x probability + etc.). So the jackpot’s contribution to the total expected value of a Powerball ticket can drop \$.024. Since a ticket costs \$2, we only need the jackpot’s portion of the ticket’s expected value to be \$1.76 in order to have a a ticket that’s worth what it costs—and a break-even system.

So since we know we need the expected value of the jackpot’s portion a Powerball ticket’s worth (\$1.76), we can find out how big the jackpot needs to be, just like we did in the simple version. By dividing the \$1.76 by the probability of hitting it big, adjusting for taxes, adjusting for jackpot splitting, you get… \$1.35 billion. But this is just the cash payout, which is usually three-fifths of the jackpot.

Read Next: What to Do If You Win the Powerball Jackpot

If the billboards and newscasters ever announce a \$2.3 billion Powerball, the math’s likely to be in your favor.

Now, that’s figure is with a very conservative 200 million tickets sold. If the jackpot actually gets this big, far more tickets could be sold, making the likelihood of a split higher and driving the value of a ticket down—so you’d have to again wait for an increase in jackpot size raise the expected value of a ticket. But then, of course, more people would play, and the single-winner probability would drop again. It’s a vicious cycle.

You can, however, do a few little things to increase your chances, most notably by trying to choose numbers that are off the beaten path. Think about numbers people are more likely to choose (dates, so numbers under 31, for example). Don’t choose them. Think about ways people might pick numbers, and avoid them. For instance, people tend to think winning lotto numbers will all be across the spectrum. But 43-44-41-42-40-(25) is just as likely as any other. Humans are awful at picking randomly so use that to your advantage.

Is this all realistic? Well, yeah. It’s not unheard of for a lottery to be in your favor, although it’s not likely to happen very often: \$2.3 billion is pretty high. But it could happen. And if so, remember to enjoy that \$2 dream when you play.

*You can very roughly estimate the number of tickets sold by taking the growth of the lump sum payout option from an unwon drawing to the next and multiplying by 3/2.

EDIT POST