function [u,it] = NejvetsiSpad(A,b,u0,prec,itMax)

u = u0;
r0 = b-A*u;
normr0 = sqrt(r0'*A*r0);
normr = normr0;
r = r0;
it = 0;

while normr>prec*normr0 && it<itMax
    alfa = r'*r/normr^2;
    u = u + alfa*r;
    r = b-A*u;
    normr = sqrt(r'*A*r);
    it = it+1;
end

