numpy.lcm () in Python



numpy.lcm (arr1, arr2, out = None, where = True, casting = & # 39; same_kind & # 39 ;, order = & # 39; K & # 39 ;, dtype = None ) : this math function helps the user to compute the lcm value for | arr1 | and | arr2 | elements.

Parameters:
arr1 / arr2: [array_like] Input array.

Return: LCM of two or more numbers.

Code:

# 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 ( "lcm of arr1 and arr2:" , np.lcm (arr1, arr2))

print ( "lcm of arr1 and 10 :" , np.lcm (arr1, 10 ))

 

Output:

 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]