%computes factorization of P(x) = a(1)+a(2)*x+...+a(n+1)*x^n as
%P(x) = c_0+c_1*(x-r)+...+c_n*(x-r)^n, where n+1=length(a)
%output displays coefficients c_0,...,c_n in order

a = [3,-4,-1,1]    %coefficients of P(x)
n = length(a)-1;
r = 2;

for k=1:n
    for j=n:-1:k
        a(j) = a(j+1)*r+a(j);
    end
    a(k)
end
a(n+1)

