Hello everyone, welcome to **nkcoderz.com**. In this article we will going to discuss about Python program to find LCM of the given 3 numbers.

Table of Contents

## Code for python program to find LCM of the given 3 numbers

```
def lcm(a, b, c):
# Find the greatest common divisor of the three numbers
def gcd(x, y):
while y:
x, y = y, x % y
return x
# Find the LCM of the three numbers
lcm = (a*b*c)//(gcd(a,gcd(b,c)))
return lcm
# Test the function
print(lcm(5, 7, 9))
```

## Output

315

## Explanation

The program defines a function `lcm`

that takes in three numbers as arguments (`a`

, `b`

, and `c`

). Inside the `lcm`

function, there is another function called `gcd`

which finds the greatest common divisor of two numbers by using Euclidean algorithm.

Then LCM is calculated using the formula (a*b*c)//(gcd(a,gcd(b,c))) which ensures the LCM is found of 3 numbers by the concept of transitive property of GCD and LCM.

Python program to check the given number is Adam’s number

## Conclusion

If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.