function [B] = solution_hw6_p3(A, n)

    [U, S, V] = svd(A);

    S = diag(S);
    
    rnk = rank(A);
    
    B = zeros(size(A));
    
    for i=1:min(n, rnk)
       B = B + S(i)*U(:,i)*V(:,i)';         
    end
    
    
    
    

end

