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类数组,int

值的数组.如果 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])