📜  Python中的 numpy.lcm()

📅  最后修改于: 2022-05-13 01:54:26.809000             🧑  作者: Mango

Python中的 numpy.lcm()

numpy.lcm(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) :这个数学函数帮助用户计算 |arr1| 的 lcm 值和 |arr2|元素。

代码 :

# Python program illustrating 
# lcm() method 
import numpy as np 
  
arr1 = [120, 24, 42, 10]
arr2 = [2250, 12, 20, 50]
  
print ("arr1 : ", arr1)
print ("arr2 : ", arr2)
  
print ("\nlcm of arr1 and arr2 : ", np.lcm(arr1, arr2))
print ("\nlcm of arr1 and 10   : ", np.lcm(arr1, 10))
                     

输出 :

arr1 : [120, 24, 42, 10]
arr2 : [2250, 12, 20, 50]

lcm of arr1 and arr2 : [9000,   24,  420,   50]

lcm of arr1 and 10   : [120, 120, 210,  10]