I am trying to write something in PARI/GP
.
I want to create a vector with the values from 1000 to 41000 in steps of 3000.
Therefore, I wanted to use the forstep statement. This works fine if you use 1 sequence.
Example:
forstep(x=1000,41000,3000,print(x))
However, I want to do something like:
forstep(x=1000,41000,3000,x[i]=x & i=i+1)
How to do this?
One way of making your approach work, is:
I put a parenthesis around each assignment. Otherwise, PARI/GP sees it as
v[i]=(x & (i=i+1))
. So in some cases you can combine two expressions with&
.However: The operator
&
will short-circuit if its first operand is zero (seen as false). So the answer you are looking for, is the semicolon;
. So:I believe a construct with semicolon like
v[i]=x; i=i+1
is called a sequence in the PARI/GP terminology.