Well, looking at http://mathworld.wolfram.com/LeastCommonMultiple.html
they first define LCM in terms of prime factorizations of the
arguments, and negative numbers do not have prime factorizations.  But
then they go on to extend the definition...

I note that most of the references there are quite recent, which
suggests invented terminology rather than any sort of stable
tradition.  There is a book from 1951 listed as a reference for that
page, I would be curious to see if it treats this issue of negative
numbers.

That said:

lcm0=: * % +.    NB. equivalent to J's definition
lcm1=: |@* % +.  NB. equivalent to Wikipedia description

The wolfram page says that least common multiple is idempotent

   (-: lcm0 )_1
0

but if we use the other definition:
   (-: lcm1)_1
0

... it still does not work.

And if we look at the distributive property:
   (_1 * lcm0/2 3 4) -: lcm0/ _1*2 3 4
1
   (_1 * lcm1/2 3 4) -: lcm1/ _1*2 3 4
0

J's definition has this distributive property where the current
wikipedia definition does not.

I guess I just need to ignore negative arguments, if I want a
consistent definition for LCM.

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

Reply via email to