In this program, we have explained how to find the LCM (Least Common Multiple) numbers using the c++ programming language.
below is the formula to calculate the LCM (Least Common Multiple) numbers from given numbers.
We are going to find the LCM number of 24 and 60. On the basis of above LCM formula:
using namespace std;
int a, b, max;
cout << "Enter two numbers to find LCM: ";
cin >> a >> b;
// maximum value between a and b is stored in max
max = (a > b) ? a : b;
if (max % a == 0 && max % b == 0)
cout << "LCM is = " << max;
} while (true);
Enter two numbers to find LCM: 24
LCM is: 120
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari