I tried making a program to find the lowest common multiple of any two numbers. I have gotten most of the way there but my program prints all of the common multiples from 1-1000000 instead of just the first one. How do I make it print only the first one ?
#include <iostream>
using namespace std;
int main() {
cout << "Find the lowest common multiple of two numbers, just enter them one after the other" << endl;
int firstNum;
int secondNum;
cin >> firstNum;
cin >> secondNum;
int i;
for (i = 1; i < 1000001; i++) {
if (i % firstNum == 0 && i % secondNum == 0) {
cout << "these two number's LCM is" << i << endl;
}
}
system("pause");
return 0;
}