program binomial;
uses wincrt;
var
n,x,i: integer;
f,g,n_x,c,px,qx,b,p,q,r:real;
begin
write ('Masukkan nilai n='); read(n);
write ('Masukkan nilai x='); read(x);
write ('Masukkan nilai p='); read(p);
f:=1;
g:=1;
q:=(1-p);
r:=n-x;
n_x:=1;
for i:=2 to n do
f:=f*i;
for i:=2 to x do
g:=g*i;
for i:=2 to (n-x)do
n_x:=n_x*i;
c:=f/(g*n_x);
px:=1;
for i:=1 to abs (x) do
px:=p*px;
qx:=1;
for i:=1 to abs (n-x) do
qx:=q*qx;
b:=c*px*qx;
write (c,px,qx);
writeln('b=',b);
end.
Tidak ada komentar:
Posting Komentar