How to get the total length of a Row Vector in PARI/GP

1.2k Views Asked by At

from the divisors of a certain number, im trying to randomly choose a divisor.

However i am unable to randomly get a number as i could not find any function that can get me the length of a row vector.

example:

temp=divisors(12);
[1,2,3,4,6,12]
vecmax(temp); \\will get me 10 instead of 6
temp[random(vecmax(temp))];

Hopefully someone here can help me with this. Thanks! :)

1

There are 1 best solutions below

1
On BEST ANSWER

temp=divisors(12);

\\contents of temp : [1,2,3,4,6,12]

print(length(temp));

\\output : 6