function pi = pi_MC( n )

count=0;
rng(0,'twister');
a=-1;
b=1;
x=(b-a).*rand(n, 1)+a;
y=(b-a).*rand(n, 1)+a;


for k=1:n 
    m=x(k)^2+y(k)^2;
    if m<=1
        count=count+1;
    end
end
pi=4*count/n;
end

