octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lcm(0,n) gives 0 which should be changed.


From: Jordi Gutiérrez Hermoso
Subject: Re: lcm(0,n) gives 0 which should be changed.
Date: Sun, 25 Mar 2018 18:23:38 -0400

On Sat, 2018-03-24 at 10:29 -0700, Dildar Sk wrote:
> > > lcm(0,10)
> 
> ans = 0

I don't think this is an error and I think Matlab is being excessively
restrictive.

0 is indeed the least common multiple of 0 and 10, since you can
multiply 0 and 10 by something and get 0, and 0 is the smallest number
that can be a multiple of both.

I suppose you can argue that 0 is always the lcm of any two
nonnegative integers and the output of lcm should positive to rule out
0. I think it makes more sense to return something here since one of
the inputs is zero, instead of erroring out.

In general, Matlab considering some inputs to be an error when Octave
does not is acceptable. For example, Octave can handle the Gaussian
integers:

    gcd (7+6i, 6-2i)
    ans = -1 + 2i

I belive Matlab does not accept complex arguments for gcd.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]