You can use the Kelly Criterion [0] to compute the optimum bet amount given the odds, the payoff, the cost of a ticket, and the size of your bankroll.
Usually the optimum bet is zero because the expected value is negative.
But when the jackpot gets big enough, occasionally the Kelly Criterion will advise buying a ticket or two if your bankroll is really big, like $10 million.
[0] https://en.wikipedia.org/wiki/Kelly_criterion