P.S. the english describing this problem here should be fixed.

The smallest positive number which divides 1+i.n evenly is 1 and a 1:
would be a verb to compute that value.

The number being computed here is the smallest positive number which
1+i.n divides (with an integer result).

(If we allowed negative or fractional values we would... have other issues ...)

Sometimes the words matter, I am not sure if this is one of those
cases, but it's still pretty easy to fix here.

Thanks,

-- 
Raul

On Sun, Mar 10, 2019 at 4:00 PM Eugene Nonko <eno...@gmail.com> wrote:
>
> I need to find the smallest number that divides all numbers from 1 to n.
> The solution, of course is this:
>
> *./ >: i. n
>
> What I don't understand is why this solution seems to scale so poorly:
>
>    6!:2 '*./ >: i.10000x'
> 0.326128
>    6!:2 '*./ >: i.11000x'
> 1.00384
>    6!:2 '*./ >: i.12000x'
> 4.133
>    6!:2 '*./ >: i.13000x'
> 11.8082
>
> When I perform similar calculation in Haskell it produces result in
> negligible time, even when n = 100,000.
>
> λ: foldr1 lcm [1 .. 100000]
> 695283836241707197000307586...
>
> If I use a verb other than *. it runs very quickly, as expected.
>
> What's so special about LCM?
>
> Thanks,
> Eugene
> ----------------------------------------------------------------------
> 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