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?

-Dan



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to