Home >>Cpp Programs >C++ Program to find LCM of two numbers
In this example, we will see a C++ program through which we can find LCM of two numbers.
LCM of two given numbers m and n is determined by finding the smallest number that is divisible by both the given numbers.
Program:
#include <iostream>
using namespace std;
int main()
{
int m,n,max;
m=25;
n=55;
if(m > n)
max= m;
else
max = n;
while(true)
{
if (max % m == 0 && max % n == 0)
{
cout << "LCM of "<<m<<" and "<<n<<" = "<< max;
break;
}
else
max++;
}
return 0;
}