function [L,U] = simpleludecomploops(A)
%SIMPLELUDECOMPLOOPS - factor matrux A into a product of upper- 
%                      and lower- triangular matrices

% This version of the code uses loops 

    [n, ~] = size(A);
    L = eye(n);

    % Forward elimination
    for k = 1:n-1
        for i = k+1:n
            mult = A(i,k)/A(k,k);
            L(i,k) = mult;
            A(i,k) = 0;
            for j = k+1:n
                A(i,j) = A(i,j) - mult*A(k,j);
            end
        end
    end

    U = A;

end
