Find the LCM of two given numbers Test Case 1 Input (stdin) 3 4 Expected Output 12 Test Case 2 Input (stdin) 6 5 Expected Output 30
#include <iostream>
using namespace std;
int main()
{
int n1, n2, max;
cout << " ";
cin >> n1 >> n2;
// maximum value between n1 and n2 is stored in max max = (n1 > n2) ? n1 : n2;
do { if (max % n1 == 0 && max % n2 == 0) { cout << " " << max;
break;
}
else ++max;
}
while (true);
return 0;
}