clear();
var= 0;
esp = 0;
ESP = 0;
VAR = 0;
N = 50;
n=1000;
p = 0.2;
random = 0;

for j=0:n
    esp=0;
    var=0;
    for i=0:N
        random=rand();
        if random<p then
            esp=esp+1;
        end
    end
    ESP = ESP + esp/n;
    VAR = VAR + (esp*(esp/n))
end

Esperance = ESP;
Esperance = N*p;
VAR = VAR - (ESP)*(ESP);
Variance = VAR
Variance = (N*p)*(1-p);

disp(ESP);
disp(VAR);
