Calculate your Lotto Odds!
Part of Gerry Quinn's Mathematical Games Site  check out my other Java and Windows puzzle games!
This applet will calculate the odds of winning a Lotto prize from a single ticket.
This modified version was released on 27 October 1999. It has dropped some of the excess decimal places, and resorts to scientific notation only in extreme cases. This is easier to read but note that there may be too few significant figures in either the 'odds' or 'chance' readout. (Alteration based on a suggestion by Ed Pegg Jr, who runs an excellent math and puzzle site at www.mathpuzzle.com .)
Your Lotto must operate similarly to the Irish version. In this, there is a drum containing 42 numbered balls, from which 6 are drawn. On each ticket you must mark 6 numbers. Depending on how many numbers you get right, you win a prize  the Jackpot prize is shared by those who get all 6 numbers right. If there is nobody with 6 numbers, the Jackpot is rolled over until the next draw.
A seventh ball, the "bonus number" is also drawn. It takes no part in the major prizes, but a smaller prize is given for getting three numbers plus the bonus number correct.
If your local lottery works like this, but with different numbers of balls, you can use the applet to calculate your odds. Just enter the figures for your own lottery, and press "Enter" or click the mouse anywhere on the applet. Check the "Bonus" box only if the combination requires it (e.g. in the Irish Lotto, check it for 3 numbers plus the bonus, but not for your Jackpot chances).
It is assumed that you pick as many numbers as there are balls drawn (6 in this case), and that you are not so dim as to pick any number twice.
The applet will change the numbers if they do not make sense. This may lead to unexpected changes; for example, if you have selected six correct numbers out of six, and then specify a bonus number as well, your selection will be changed to five numbers and a bonus. The new values will of course be shown in the applet window.
The maximum number of balls is one million. If you use numbers this large, it may take a little time to calculate the odds. Wait for the calculation advice line ("Calculating 42, 6, 6, N") which will change when the calculation is complete.
Some rather silly numbers can be obtained! Your chance of suddenly dying while reading this sentence is much greater than 1 in 10^20. To join in a lottery with worse odds than this might be considered excessively optimistic.
My advice? Ponder the odds and save your money!
If you feel like a stiff dose of probability calculations, the formula is explained here.
Note: you will need a basic knowledge of probability calculations to understand this moderately complex problem. If you are interested in this sort of thing read on; if not, you can still use the applet!
Consider a lottery where there are initially 42 balls, and six are drawn. What are the odds of getting exactly three numbers correct (out of the list of six you selected)?
Something like the following will happen:
Overall odds of this exact sequence occurring:
However, there are other orders in which the balls might have come out, 19 of them in fact  the number of combinations of three items taken from six is 6! / 3! 3! = 20. Therefore the chances of getting three numbers is 20 times the above or 0.02722185008.
You will note that irrespective of the order of drawing, the numerator will be 36.35… for wrong balls, and 6.5… for correct ones. For example, a different order of drawing would have given (36/42)(35/41)(34/40)(6/39)/(5/38)(4/37)  but the product is exactly the same. So we can multiply the calculated chance of a single sequence by the number of different sequences (20) that will lead to the same overall result (three hits).
The above should be clear enough, but it is possible to write down the equation in factorial form.
Let 
B = Total number of balls (42) 

D = Number drawn = Number selected (6) 

H = Number correct ('Hits') (3) 
The probability is (read on only if you have no fear of equations):
BD! D! BD! D!
P = 
B2D+H! DH! B! H! DH!
What about the bonus number? Well, the bonus ball is one of the 36 balls not so far drawn, and you have still 3 numbers in your list that might be it. So, the probability of getting three numbers plus the bonus number is onetwelfth the probability of getting three numbers alone, or 0.002268.
The applet simply implements the above equation. If you don't trust it, try adding up the odds for 0 hits, 1 hit, 2 hits, … 6 hits. You will find that they total 1.000, as they should. Hardly a proof, but it may inspire some confidence!