1) Distribusi Eksponensial
program expo;
uses wincrt;
var
i,
n:= integer;
e,
f:= real;
begin
e:=
1; i:= 0; n:= 10; f:= 1;
repeat
f:=
f*i;
e:=
e + 1/f;
until i:= n;
writeln ('e=', e: 11: 4);
end.
2) Distribusi Binomial
program binomial;
uses wincrt;
var
i,j,k,n,x: longint;
a,b,c,d,e,p: real;
begin
readln
(n);
readln
(x);
readln
(p);
a:=
1;
b:=
1;
c:=
1;
d:=
1;
e:=
1;
for
i := 1 to n do
a:=
a*i;
for
j := 1 to x do
begin
b:=
b*j;
c:=
c*p;
end;
for
k:= 1 to (n-x) do
begin
d:=
d*k;
e:=
e*(1-p);
end;
writeln
(a/(b*d)*c*e: 0: 4);
end.
1 komentar:
Ayo coba pake 'jump break' nya, dilihat gimana hasil nya..
Posting Komentar