Question

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

Was it helpful?

Solution

temp=divisors(12);

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

print(length(temp));

\\output : 6

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top