


for k=1:1:n-1
    for i=k+1:1:n
        fac = (a(i,k)) / (a(k,k));
        for j=k+1:1:n
            a(i,j) = a(i,j) - fac * (a(k,j));
        end
        b(i) = b(i) - fac*(b(k));
    end
end

x(n) = (b(n)) / (a(n,n));

for i=n-1:1:-1
    sum = b(i)
    for j=i+1:1:n
        sum = sum - (a(i,j))*x(j);
    end
    x(i) = sum /  (a(i,i));
end
