>From http://www.jsoftware.com/jwiki/Essays/Divisors

   div=: /:~ @: , @: > @: (*/&.>/) @: ((^ i.@>:)&.>/) @: (__&q:)
   div 360
1 2 3 4 5 6 8 9 10 12 15 18 20 24 30 36 40 45 60 72 90 120 180 360





On Tue, Jun 10, 2014 at 10:10 AM, Jon Hough <[email protected]> wrote:

> My attempt at making a verb that finds the total of all proper divisors of
> an integer seems to work.
> e.g. if n = 12, the sum of proper divisors is 1 +2 +3+4+6 = 16 (note 12 is
> not included)
> This verb is actually equal to the "sigma function" minus n.Wikipedia
> explanation: http://en.wikipedia.org/wiki/Divisor_function
> (I essentially used the equation for sigma_x(n) where x = 1)
> my verb:
>
> sum =.(((*/@:-&1@:{.)%~(*/@:-&1@:({.^(1&+@:,@:}.))))@:(2&p:))-]
> This seems ok, but is not aesthetically pleasing, and seems to be very
> bracketty, and given that the mathematical equation is pretty concise I am
> surprised the J verb is so long. If anyone knows a nicer way of doing this
> I would be grateful to see it.
> Regards.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to