I've got a .txt file, which contains a sequence of numbers as follows:
a_1
+a_2
+a_3
+a_4
+a_5
...
Fix some positive integer n
. Using Pari/GP, how can I write down the sequence [a_1, a_1 + a_2*n, a_1 + a_2*n + a_3*n, ...]
as a Pari/GP vector? I've been told that I shold use concat(-,-)
, but I don't know how to do utilize the command.
If I create a file C:\temp\example.txt
with the contents:
100 +300 +301 +10101
then I can use the following:
gp > a=readvec("C:\\temp\\example.txt")
%1 = [100, 300, 301, 10101]
gp > b=vector(#a,i,a[1]+n*sum(j=2,i,a[j]))
%2 = [100, 300*n + 100, 601*n + 100, 10702*n + 100]
Here a
is simply a vector representation of the file lines, and b
is a vector with #a
components whose i
th entry is a[1]
plus n
times the sum from j=2
to i
of a[j]
.
You could also assign a value to n
, like n=666
, before you declare b
.
Hope this was what you meant.