[Jprogramming] Simple example with (@.) 'Agenda'

Martin Kreuzer info at airkreuzer.com
Tue Jul 12 16:41:26 UTC 2016


Pascal -
Thanks for the quick answer;
I already worked the example from the NuVoc page 
using the prime exponents from (_ q:), I 
mentioned it here simply as a reference for result values.
My idea has been to stick with the straight approach (as an exercise) ...
-M

At 2016-07-12 16:14, you wrote:

>__ q: each 16 17 18
>┌─┬──┬───┐
>│2│17│2 3│
>│4│ 1│1 2│
>└─┴──┴───┘
>
>
>gives divisors as 2 rows with exponents as 2nd.
>
>
>_ q: each 16 17 18
>┌─┬─────────────┬───┐
>│4│0 0 0 0 0 0 1│1 2│
>└─┴─────────────┴───┘
>
>
>just the exponents.
>
>the 2nd program just increases these by 1, and takes product.
>
>
>
>----- Original Message -----
>From: Martin Kreuzer <info at airkreuzer.com>
>To: programming at jsoftware.com
>Sent: Tuesday, July 12, 2016 12:03 PM
>Subject: [Jprogramming] Simple example with (@.) 'Agenda'
>
>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
>----------------------------------------------------------------------
>For information about J forums see http://www.jsoftware.com/forums.htm



More information about the Programming mailing list