numpy.lcm#

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

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

参数:
x1, x2类数组, 整数

值数组。如果 x1.shape != x2.shape,它们必须能够广播成一个共同的形状(这将成为输出的形状)。

返回:
yndarray 或标量

输入的绝对值的最小公倍数。如果 x1x2 都是标量,则结果为标量。

另请参阅

gcd

最大公约数

示例

>>> import numpy as np
>>> 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])