See http://www.jsoftware.com/jwiki/Essays/Under under "Primes and factoring".
----- Original Message ----- From: Dan Bron <[email protected]> Date: Friday, January 7, 2011 10:22 Subject: Re: [Jprogramming] A small arithmetic problem To: 'Programming forum' <[email protected]> > I wrote: > > that J allows us to express LCM elegantly! Compare > > >./&.(_&q:) to the formulas given on the Wikipedia page. > > By the way, GCD (+.) is analogously > <./&.(_&q:) > > (<. in place of >.). > > Let's play with f/&.(_&q:) some more. First, let's make it > a reusable > adverb: > > > ruf > =: / ( &.(_&q:) ) NB. Reduce Under Factorization > > N =: @:(>:@:i.) > NB. First N positive ints > > rufN =: ruf N > > Now let's verify our observations: > > >. > rufN 20x NB. LCM > 232792560 > > <. rufN > 20x NB. GCD > 1 > > Now, let's expand our minds: > > + > rufN 20x NB. Guess! > 2432902008176640000 > > ! > 20x NB. Hint.... > 2432902008176640000 > > That is, just as >. ruf is *. and <. ruf is +. , so + ruf is > * ! It > bears repeating: > > > A ... expression like *./ refreshes my appreciation of > J's > > design; it's close to * / which is the "obvious" > common > > multiple of the vector. > > Are there any other f for which f ruf or f > rufN are interesting? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
