How do I declare and call array in PARI/GP?
For example, I have the following in java:
int[] myArray = new int[5];
for(int i = 0; i < 5; i++){
myArray[i] = i + 5;
}
How do I do the same thing while using PARI/GP?
How do I declare and call array in PARI/GP?
For example, I have the following in java:
int[] myArray = new int[5];
for(int i = 0; i < 5; i++){
myArray[i] = i + 5;
}
How do I do the same thing while using PARI/GP?
The usual way is
where I have replaced
i+5
withi+4
because GP vectors are 1-based, not 0-based.You could also do
if you prefer. (This is useful in some cases, e.g., when you want to refer to earlier values in the array.)