Mark Wickens

5 ONERRORGOTO500
10 IFp=1 THENIFn=x THENs=1:f=1:GOTO80 ELSEs=0:f=0:GOTO80
20 q=1-p:f=q^n:s=f:z=p/q:y=n+1
30 FORi=1 TOx:f=f*z*(y-i)/i:s=s+f:NEXT
80 s=1-s+f:RETURN
500 IFERR=1 THENCLS:ONERRORGOTO0
510 sr=1:RESUME80