ThibThib's answer is absolutely correct, but it is not very generalized if a occurs with a vector. So, as a starting point:
> a= 2 a = 2 > n= 3 n = 3 > a.^[0: n] ans = 1 2 4 8
Now you can also use the built-in vander function (although the order is different, but it is easily fixed if necessary) to create:
> vander(a, n+ 1) ans = 8 4 2 1
And with the vector value a :
> a= [2; 3; 4]; > vander(a, n+ 1) ans = 8 4 2 1 27 9 3 1 64 16 4 1
eat
source share