numpy.lcm

numpy.lcm(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'lcm'>

返回的最小公倍数 |x1||x2|

参数
X1,X2类数组

值的数组。如果 x1.shape != x2.shape ,它们必须可以广播到公共形状(成为输出的形状)。

返回
yndarray或scalar

输入绝对值的最小公倍数如果两者都是,则这是一个标量。 x1x2 是标量。

参见

gcd

最大公约数

实例

>>> np.lcm(12, 20)
60
>>> np.lcm.reduce([3, 12, 20])
60
>>> np.lcm.reduce([40, 12, 20])
120
>>> np.lcm(np.arange(6), 20)
array([ 0, 20, 20, 60, 20, 20])