a = [2,4,5]
x = 3
n = length(a);

v = a(1);
z = x;

for i=2:n
    v = v+z*a(i);
    z = x*z;
end

disp('and the answer is...')
v
z