Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created September 25, 2021 09:09
Show Gist options
  • Save amankharwal/be9310806a26315afdfed695ae39c53d to your computer and use it in GitHub Desktop.
Save amankharwal/be9310806a26315afdfed695ae39c53d to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(){
int a;
int b;
int greater;
int lcm;
cout << "Enter two numbers to find LCM: ";
cin >> a >> b;
greater = (a > b) ? a : b;
do{
if (greater % a == 0 && greater % b == 0){
lcm = greater;
cout <<lcm;
break;
}
else
greater = greater+1;
} while (true);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment