It is only worth investing when the Jackpot size is larger than the odds of the lottery.
For example, it’s only worth investing when the jackpot is larger than $292,201,338 for Power Ball.
Similarly, for Mega Million, only invest when the jackpot is larger than $258,890,850.
In 1956, a researcher in Bell Labs named J.L.Kelly, Jr described a formula to determine the optimal size of a series of vets in order to maximise the logarithm of wealth.
For simple bets with two outcomes, one involving losing the entire amount bet, and the other involving winning the bet amount multiplied by the payoff odds, the Kelly bet is:
It'd only be wise to invest the ticket when the expected payoff (prize * winning odds) is greater than the losing odds.