MODE 12
COLOUR 3
FOR d = 1 TO 3
   PRINT "Program BBC BasV ""donmcd.lotto.keno.20/80cmt"", 05.12.96, 17.07.97, 22.11.97"
   NEXT d

PRINT '"Calculate odds of  winning lower tier Lottery prizes."
PRINT"By don.mcdonald@welcom.gen.nz.  (Usenet rec.gambling.lottery.)"

PRINT'' CHR$(7)"Hit --  Kk.eno or Ll.otto:"' "     (Standard NZ Lotteries Commission shortcuts,)"'"  OR any other key,   general / other lotteries."'"6/49, 5/45, etc." '
COLOUR 7

CASE GET$ OF

WHEN "K", "k"
PRINT "Keno 20/80"
Balls = 80
lucky = 20

WHEN "L", "l"
PRINT "Lotto 6/40,  n.b. not counting special bonus no. or Powerball"
Balls = 40
lucky = 6

ENDCASE

INPUT"Balls in barrel <escape>= "; Balls
REPEAT
INPUT ' "no. of lucky balls drawn"'" (lucky 6, strike 4, incl. bonus 7, 0 exit) = ";lucky




unlucky = Balls - lucky

   REPEAT

VDU 7
   PRINT '"Balls = "; Balls '"lucky / unlucky = "; lucky " / " unlucky

INPUT '"Enter combo or how many group nos you chose,"'" (0 Ret=quit)  "; combo$
   IF combo$ = "" OR lucky = 0 THEN combo = 0  ELSE combo = VAL(combo$)
   PRINT combo
IF combo > 0  THEN

   INPUT ' "enter pattern.  e.g. Lower portion, 1..22* "; p$
   REPEAT
       INPUT "enter selection, e.g. 6*mult 8: 8,16,24--48..* yes, Ret. " '; i$
       UNTIL i$ = ""

INPUT '"Enter minimum correct = "; correct
t = FNCr(Balls, combo)
s = 0

PRINT '"Balls = "; Balls '"lucky / unlucky = "; lucky " / " unlucky
PRINT '"combo  (group)  = "; combo  ' "minimum correct = "correct
PRINT "t =(Balls, combo) = "; t'
PRINT "n_C_r = n! / (r!.(n-r)!)  =  ";Balls"! / ( ";combo"!."Balls-combo"! )."
PRINT'" c (lucky, c)x (unlucky,combo-c);" '"/correct--  wrong"TAB(20)" nr;           s;        odds = 1:t/nr |  cumul 1:t/s" ' TAB(50)"(Exact.)     ( at least.)"

FOR c = lucky TO correct STEP -1: REM  TO lucky
        nr = FNCr(lucky,c)* FNCr(unlucky,combo-c)
        s += nr
        PRINT ; c  " (";lucky "," c")x(" unlucky "," combo-c")" TAB(20); nr; TAB(35);s;
        IF s > 0 THEN PRINT TAB(50); t/nr TAB(64) t/s  ELSE PRINT
        NEXT c

   REPEAT
       INPUT "comment [Ret.] " ; c$
       UNTIL c$ = ""

ENDIF
UNTIL combo < 1
UNTIL lucky = 0

PRINT "donmcd.lotto.keno.20/80cmt   RUN. or <ESC> "GET$:  RUN

      REM  PRINT"":END

DEF FNCr(n,r)
z = r*(n-r)
IF z < 0 THEN = 0
IF z = 0 THEN = 1
x = 1
FOR i = 1 TO r
        x = x * (n+1-i)/i
        NEXT i
=x
REM -------
