Oops, off by a factor of 2. On Aug 29, 2017 13:34, "Roger Hui" <[email protected]> wrote:
> 2!>:21 > > > > On Aug 29, 2017 10:17, "Murray Eisenberg" <[email protected]> wrote: > >> The sum in question is twice the sum of the integers from 1 to 21. By the >> well-known formula (sometimes attributed to Gauss), the latter sum is half >> the product of 21 and 21 + 1, so the sum in question is >> >> */21+i. 2 >> 462 >> >> >> > On28 Aug 2017 12:02:57 -0500,S kip Cave <[email protected] >> <mailto:[email protected]>> wrote: >> > >> > 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? >> >> —— >> Murray Eisenberg [email protected] >> Mathematics & Statistics Dept. >> Lederle Graduate Research Tower phone 240 246-7240 (H) >> University of Massachusetts >> 710 North Pleasant Street >> Amherst, MA 01003-9305 >> >> >> >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
