Input "SUCCESSES",X
Input "TRIALS",N
Input "CONF LEVEL",G
0.5+G÷2⇒C
Gosub Q
M⇒H
0.5-G÷2⇒C
Gosub Q
M⇒I
If X=0
Then
0⇒H
EndIf
If X=N
Then
1⇒I
EndIf
Print H
Print I
End
Label Q
0⇒L
1⇒U
1-C⇒A
0-C⇒B
0.000001÷N⇒E
While (U-L)>E
(U+L)÷2⇒M
cdfbin(N,M,X)⇒P
P-0.5×pdfbin(N,M,X)⇒P
P-C⇒D
If A×D>0
Then
M⇒L
D⇒A
Else
M⇒U
D⇒B
EndIf
WEnd
(U+L)÷2⇒M
Return
