A simple problem posted on Quora:

What is the sum of all the even numbers from 2 to 42?

My J solution:
   a=:>:i.42
  +/(-.2|a)#a
462

I'm sure this can be done in a single line using a hook or fork.
but I'm not clear enough with the train rules to put this all together
on a single line.
Any suggestions?





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

Reply via email to