Disp "Clop-Pear mid-P"
Input "Successes:",X
Input "Trials:",N
Input "Confidence:",C
If X<0 or N<X or fPart(X)!=0 or fPart(N)!=0 or N<=0
Goto 2
If C>=1 or C<0
Goto 2
1-(1-C)/2->A
If X!=0
Then
	solve(binomcdf(N,P/N,X)-0.5(binompdf(N,P/N,X))-A,P,0.5*N,{0,N})/N->L
	Else
	0->L
End
If X!=N
Then
	solve(binomcdf(N,P/N,X)-0.5(binompdf(N,P/N,X))+A-1,P,0.5*N,{0,N})/N->R
	Else
	1->R
End
Disp L
Disp R
Stop
Lbl 2
Disp "DOMAIN ERROR"
Return
Stop