Search code examples
vectorrowpari-gp

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


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! :)


Solution

  • temp=divisors(12);

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

    print(length(temp));

    \\output : 6