Hi all -
Tried a _straight approach_ to answer the question "How many divisors
does an (integer) number have?" ...
Hope my math is correct:
Check divisibility for all integers from 1 to floor of number's (square) root;
count number of divisor product pairs;
double that to get number of divisors and
subtract 1 in case of a square (integer root) which sports one
symmetrical pair.
This is what I put together:
dn=. 13 : '(<:)`(]) @. (* (|~ %:) y) +: +/ -. * (>: i. <. %: y) | y'("0)
dn 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2
As a comparison, here are the results using the example verb from the
NuVoc/ Prime Exponents page:
don=. 13 : '*/ >: _ q: y'("0)
don 16 17 48 49 1024 1025 1103
5 2 10 3 11 6 2
Guess verb (dn) can be written in a more compact way, sort of
"folding it" as it obviously has similar structural elements;
Q: Would someone have the time and patience to gently guide me through this..?
Thanks
-M
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm