function [ret,steps]=aufg06f04(A)

n = size(A,1);
steps = zeros(n,1);
ret   = zeros(n,1);

for k=n:-1:2,
    shift=A(k,k);
    I=eye(k,k);
    while aufg06f03(A)==0,
        steps(k)=steps(k)+1;
        [Q,R]=qr(A-shift*I);
        A=R*Q+shift*I;
        shift=A(k,k);
    end
    ret(k)=A(k,k);
    A=A(1:k-1,1:k-1);
end
ret(1) = A(1,1);
