Our FREE site is mostly funded by the Amazon ads ⇓below⇓.
Support us by clicking ⇑above⇑ next time you plan to buy a product on Amazon.
// C program to find LCM of two numbers
suppose we have two numbers a and b.
Property: Since product of LCM and GCD of two numbers are equal to product of that number itself.
So,here we first find the GCD of two numbers and using above property we find LCM of that two numbers.
// Recursive function to return gcd of a and b
int gcd(int a, int b)
if (a == 0)
return gcd(b % a, a);
// Function to return LCM of two numbers
int lcm(int a, int b)
return (a*b)/gcd(a, b);
// Driver program
printf("Enter two numbers to find their LCM \n");
printf("LCM of %d and %d is %d ", a, b, lcm(a, b));