I want to find all the integer factors of a positive integer,
which includes 1 and the integer.
Here's a brute force verb I wrote:
fac=:3 : 'a#~0=(a=.1+i.y)|y'

Test it:

fac each 40+i.5

│1 2 4 5 8 10 20 40│1 41│1 2 3 6 7 14 21 42│1 43│1 2 4 11 22 44│


However my fac verb is inefficient, slow, and runs out of memory quickly on
larger integers. Is there a way to take advantage of J's prime factoring
verb q: to more efficiently find and/or count *all* positive factors (not
just primes) of a large (>1e7) integers?


Skip


Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to