code 41254;
real procedure NEGBINPROB(X, K, P);
    value X, K, P; real X, K, P;
NEGBINPROB:= if K < 0 ∨ K > ENTIER(K)
             then STATAL3 ERROR(“NEGBINPROB”, 2, K)
             else if P ≤ 0 ∨ P > 1
             then STATAL3 ERROR(“NEGBINPROB”, 3, P)
             else if X < K ∨ X > ENTIER(X) then 0
             else if P = 0 then 0
             else if P = 1 ∨ K = 0
             then (if X = K then 1 else 0)
             else P × BINPROB(K - 1, X - 1, P);
eop