Open ckrause opened 7 months ago
simple test for two vectors:
? V=vector(10)
%1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
? W=vector(10)
%2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
? V[1]=1
%3 = 1
? W[1]=1
%4 = 1
? for(i=2, 10, V[i]=V[i-1]+W[i-1]; W[i]=i)
? V
%6 = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46]
? W
%7 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Preparation work done:
$ ./loda export -o pari-vector A58
(a[n] = b[n]+1); (b[n] = b[n-1]*(b[n-1]+1)); (b[0] = 1)
For faster computation using PARI, use vectors to cache previously computed terms, e.g. for
a(n)=if(n<2,1,a(n-1)+a(n-2))
use