#include <iostream> using namespace std; int main() { int a=7, b=5, lcm; if(a>b) lcm = a; else lcm = b; while(1) { if( lcm%a==0 && lcm%b==0 ) { cout<<"The LCM of "<<a<<" and "<<b<<" is "<<lcm; break; } lcm++; } return 0; }
OUTPUT:–
The LCM of 7 and 5 is 35