Message360877
Uses for lcm are common enough that it is provided by Excel and the C++ boost. You can use it for working out problems like:
- if event A happens every 14 days, and event B happens every 6 days, then A and B will occur together even lcm(14, 6) days.
By the way, the "trivial" implementation given in the Stackoverflow link has a bug: if both arguments are zero, it raises instead of returning zero.
I wish that gcd took an arbitrary number of arguments, I often need to find the gcd of three or more numbers, and this is a pain:
gcd(a, gcd(b, gcd(c, gcd(d, e)))))
when I could just say gcd(a, b, c, d, e) and have it work. Likewise of lcm. (For that matter, the gcd of a single number a is just a.) |
|
Date |
User |
Action |
Args |
2020-01-28 14:26:11 | steven.daprano | set | recipients:
+ steven.daprano, lemburg, rhettinger, mark.dickinson, vstinner, stutzbach, Ananthakrishnan |
2020-01-28 14:26:11 | steven.daprano | set | messageid: <1580221571.52.0.695755214424.issue39479@roundup.psfhosted.org> |
2020-01-28 14:26:11 | steven.daprano | link | issue39479 messages |
2020-01-28 14:26:11 | steven.daprano | create | |
|