======CPMIDP  ======
"Number of successes"?→X
"Number of trials"?→N
"Confidence level (e.g. 0.95)"?→G
0.5+G÷2→C
Prog "CPMIDQ"
M→H
0.5-G÷2→C
Prog "CPMIDQ"
M→I
If X=0
Then 0→H
IfEnd
If X=N
Then 1→I
IfEnd
{H,I}

======CPMIDQ  ======
0→L
1→U
1-C→A
0-C→B
0.000001÷N→E
While (U-L)>E
(U+L)÷2→M
-0.5×BinomialPD(X,N,M)+BinomialCD(X,N,M)-C→D
If A×D>0
Then M→L
D→A
Else M→U
D→B
IfEnd
WhileEnd
(U+L)÷2→M
M