Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Sep 25, 2021
Embed
What would you like to do?
#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