Write a program to find LCM Test Case 1 Input (stdin) 12 18 Expected Output LCM = 36 Test Case 2 Input (stdin) 20 60 Expected Output LCM = 60
#include <iostream>
using namespace std;
int main() {
int a, b, lcm;
cin>>a;
cin>>b;
if(a>b)
lcm = a;
else
lcm = b;
while(1) {
if( lcm%a==0 && lcm%b==0 ) {
cout<<"LCM = "<<lcm;
break;
}
lcm++;
}
return 0;
}