-
-
Save amankharwal/be9310806a26315afdfed695ae39c53d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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