Question: storing numbers in vector from a loop within a proc

I am interested in taking a complex number and repeatedly raising it to a power and graphing the result to see if it looks cool (i think it will) to do this i wrote this program

iterativepower := proc (base, index, n)

local out, i;
out := vector(n+1, 1);

out[1] := base;

for i to n do out[i+1] := out[i]^index end do;

out;

end proc;


this can be run with:

iterativepower(2, 2, 5)


This doesn't return a vector, it returns the word out. Why is that, and how do i fix it?

Please Wait...