On Wed, May 4, 2016 at 10:35 PM, Geoff Canyon <[email protected]> wrote:
> So I tried to write code to solve the general case of Project Euler problem
> 1. The problem given is to find the sum of all the positive integers less
> than 1000 that are divisible by 3 or 5. Obviously the specific case is
> highly optimizable. But I wanted to solve the general, with any number of
> divisors and any upper limit.

...
> Here's the code. As always, I suck at J, so improvements/suggestions are
> welcome.
>
> pe1 =: +/@(([:i.]) * 1&-@(0&i.)@*/"1@|:@(|"0 1 i.))

Maybe:
  pe1=: [:+/@I. 0 +./ .= (|/ i.)

?

Assuming email anti-spam bots do not eat my line for including an @
character. Maybe, instead:

  pe1=: [:+/ [:I. 0 +./ .= (|/ i.)

...

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to