3{.5*20+i.199-19
100 105 110
_3{.5*20+i.199-19
985 990 995
+/5*20+i.199-19
98550
<.999%5
199
Is where you get 199 from, and 20*5 is 100, so that is how you get the
range. It is simpler to just multiply the shortened range by 5 and sum it
than to filter it.
If you are trying to impress people with your short solution,
+/5*20+i.180
Is shorter, and it does not require the creation of intermediate variables.
On Jan 16, 2018 23:40, "Skip Cave" <[email protected]> wrote:
I want to find the sum of all the three-digit numbers that are divisible by
5 (Quora problem).
My explicit solution is:
+/a#~0=5|a=.100+i.900
98550
To find a tacit version:
sm=. +/a#~0=5|a=.100+i.900
sm
[: ([: +/ ] #~ 0 = 5 | ]) (100+i.900)"_
Is there a more compact way to express this function tacitly?
Skip
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm