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, x2array_like, 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])