Smallest multiple: Difference between revisions
→{{header|Python}}: Pruned out int() (redundant with integer division operator //). Extended domain of lcm to avoid division by zero errors.
(→{{header|Python}}: Second version no longer needed – first has switched to integer division and no longer errors with higher values.) |
(→{{header|Python}}: Pruned out int() (redundant with integer division operator //). Extended domain of lcm to avoid division by zero errors.) |
||
Line 512:
from math import gcd
from functools import reduce
def lcm(a, b):
""" least common multiple """
return
abs(a * b) // gcd(a, b)
)
for i in [10, 20, 200, 2000]:
|