# Python program to find the LCM of the array elements

Here, we will figure out how to discover the LCM (most minimal regular different) of the components of the array in the Python programming language?

LCM is the most minimal different of at least two numbers. Products of a number are those numbers which when partitioned by the number leave no leftover portion.

At the point when we are discussing the numerous, we think about just the positive number. For example, the LCM of 12 and 48 will be 48 on the grounds that 48 is fourth numerous of 12 and 48 is first different of 48.

Here, a variety of positive components will be given by the client and we need to discover the LCM of the components of the cluster by utilizing the Python.

To discover LCM of the components of the cluster, we will utilize a numerical equation which is:

``````    Multiple of n numbers=LCM of n numbers* (HCF of the n number)^(n-1).
``````

### Algorithm to discover the LCM of cluster components:

• Import the math module in the program.
• Take the components of a cluster from the client.
• Discover the HCF of the components of the cluster by utilizing the GCD work from the math module.
• Additionally, locate the numerous of every component of the given exhibit and allot it in a variable.
• By utilizing the above recipe simply discover the LCM of the components of the given cluster and dole out it to another variable P.
• Print the estimation of variable P which is the LCM of the exhibit’s components.

Presently, we will compose the Python program in a basic manner by actualizing the above algorithm.

### Program:

``````# importing the module
import math

# array of integers
A=[8,4,12,40,26,28]

# initialize variable b as first element of A.
b=A[0]
m=1

for j in range(1,len(A)):
s=math.gcd(b,A[j])
b=s

for k in A:
m=m*k
p=m//(b**(len(A)-1))

print("GCD of array's element:",b)
print("LCM of array's element:",p)
``````

### Output:

``````GCD of array's element: 2
LCM of array's element: 349440``````