How to compute the lowest common multiple of numbers in Python?

E.g.

lcm(10,12) = 60

E.g.

lcm(10,12) = 60

+1 vote

Best answer

Numpy has a function lcm(). You can use it to compute the lowest common multiple of numbers.

__If you have only 2 numbers:__

>>> import numpy as np

>>> np.lcm(10,12)

60

__If you have more than 2 numbers:__

>>> np.lcm.reduce([10,12,15,18,17])

3060

>>> np.lcm.reduce([2,4,8,12])

24