function k=findcut(p,n,frac);

cc=floor(p*n+0.5);

vec=binomial(p,n);
k=1;
ssum=0;
while ssum<frac
  ssum=0;
  for i=cc-k:cc+k
     ssum=ssum+vec(i+1);
  end;
  k=k+1;
end;

k=k-1;
endfunction;



