I have made a Common Multiplier (you enter 2 numbers and the program will find the lowest common multiple). I have tried it out and it works perfectly fine but I want to ask for some advice to improve this area.
#include <iostream>
usingnamespace std;
int main()
{
restart:
int number1;
int number2;
longint i;
char letter;
i = 1;
cout << "Hello. Please enter your first number." << endl;
cin >> number1;
cout << "Now, please enter your second number." << endl;
cin >> number2;
cout << "Thank you. Please allow the machine to process \nthe number's lowest common multiple." << endl;
while (i % number1 > 0 | i % number2 > 0)
{
i++;
}
cout << "The lowest common multiple of " << number1 << " and " << number2 << " is " << i << "." << endl;
cout << "Type 'Y' or 'y' to run again or press anything else to exit" << endl;
cin >> letter;
while (letter == 'Y' || letter == 'y')
{
system("CLS");
goto restart;
}
system("PAUSE");
return(0);
}
That is my code. Because my code works like 'I = 1' and keeps adding 1 to it, it processes pretty slow for high integers. Does anyone know how to speed up that bit so it can process higher numbers faster?