function[p,EX,EW]=MMnr_formulae(lambda, mu, n, r)
%clear;lambda=1;mu=1;n=1;r=5;
%lambda - intenzity (rate) of input Poisson flow, inter-arrival time = 1/lambda [s]
%mu - intenzity (rate) of service line, mean service time = 1/mu [s]
%n - number of servers
%r capacity of buffer - max. queue length
% EX- meam customers i the system(queue + service lines)
% EW - mean waiting time
rho=lambda/mu;
q=zeros(n+r+1,1);
q(1)=1;
for i=2:n
    q(i)=q(i-1)*rho/(i-1);
end

for i=n+1:n+r+1
    q(i)=q(i-1)*rho/n;
end
%Steady state distributions
p=zeros(n+r+1,1);
p(1)=1/sum(q);
for i=2:n+r+1
    p(i)=p(1)*q(i);
end

EX=sum((0:n+r)*p);
EW=EX/(lambda*(1-p(end)));



