# A Python program to find LCM(using functions)

In the earlier post we have seen how to find LCM using loops. In this post we will see how to find LCM using functions.

**#Program**

**Output**

enter value of p: 12
enter value of q: 24 LCM of 12 and 24 is 24 |

** ****Explanation:**

In the above program we are defining a function definition as “*def lcm*” and passed parameters *p* and *q*. Now initiating a loop, in that loop we are finding the highest number which is divisible by *p* and *q* as well and this number is stored in a variable called “LCM”. If it is not possible to find that number, we incremented that number by “1”.Finally function definition is called and you will be displayed the output.