[issue19237] Proposal : LCM function to complement GCD

2020-02-03 Thread Mark Dickinson
Mark Dickinson added the comment: See renewed discussion in #39479, which may lead to math.lcm being added in 3.9. -- ___ Python tracker ___

[issue19237] Proposal : LCM function to complement GCD

2013-10-23 Thread Mark Dickinson
Mark Dickinson added the comment: I'm going to reject this for the reasons already given above. It's easy to write your own (lightweight, inefficient) lcm and multi-argument gcd if you need them. For more serious work, you probably want to avoid Python's gcd anyway---it's horribly

[issue19237] Proposal : LCM function to complement GCD

2013-10-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: I am -0 (or more negative) for the same reason. The need for lcm is very rare. I think the gcd doc should give the lcm formula, with perhaps an index entry. The gcd doc might also mention that gcd is associative: gcd(a,b,c) = gcd(gcd(a,b),c). The math module

[issue19237] Proposal : LCM function to complement GCD

2013-10-13 Thread Mark Dickinson
Mark Dickinson added the comment: To get the boundary cases correct, you need a special case for lcm(0, 0), which should be 0. Did you have any particular use-cases in mind for this? It may make sense to allow multiple arguments: e.g., lcm(4, 5, 6) - 60. Overall, I'm -0 on this addition: I

[issue19237] Proposal : LCM function to complement GCD

2013-10-13 Thread CliffM
CliffM added the comment: I've handled a patch, and extended both lcm and gcd to take an arbitrary number of arguments -- via functools.reduce, as they are both multiplicative (in the first argument). Also handled the zero case , so lcm(0,0) = 0 = gcd(0,0) Use-case-wise, I do a reasonable

[issue19237] Proposal : LCM function to complement GCD

2013-10-12 Thread CliffM
New submission from CliffM: While implementing a Least-Common-Multiple function (LCM), I noticed that although python has a Greatest-Common-Divisor (GCD) function in the fractions module, the LCM, its counterpart is not there. I've attached a patch which implements and tests LCM in the

[issue19237] Proposal : LCM function to complement GCD

2013-10-12 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19237 ___ ___ Python-bugs-list

[issue19237] Proposal : LCM function to complement GCD

2013-10-12 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19237 ___ ___ Python-bugs-list