Message199687
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 amount of number-theoretic work and lcm and gcd are always popping up. If gcd is defined, it's nice to find lcm too.
For those less well versed in number-theory, the implementation of lcm is not so obvious, and many end up going down a tedious prime factorisation route -- if they get that far.
But is it all worth it in the fractions module ? They should really be in the math module. |
|
Date |
User |
Action |
Args |
2013-10-13 10:40:13 | CliffM | set | recipients:
+ CliffM, tim.peters, mark.dickinson |
2013-10-13 10:40:13 | CliffM | set | messageid: <1381660813.26.0.420329020982.issue19237@psf.upfronthosting.co.za> |
2013-10-13 10:40:13 | CliffM | link | issue19237 messages |
2013-10-13 10:40:12 | CliffM | create | |
|