C++ Programming
LCM
C plus plus example for lowest common multiple
By Geekboots
11/9/2019
0 views
lcm.cppCPP
/* Lowest Common Multiple */
#include<iostream>
using namespace std;
/* Recursive inline function */
inline int common_divisor(int x, int y) {
	/* Conditional operator to return GCD value */
	return y == 0 ? x : common_divisor(y, x % y);
}
int main() {
	int a, b, gcd, lcm;
	cout << "Enter two positive number to find Lowest Common Multiple:" << endl;
	/* read two integer from console and store it in "a" and "b" */
	cin >> a >> b;
	gcd = common_divisor(a, b);
	lcm = (a * b) / gcd;
	cout << "Lcm of two number is: " << lcm << endl;
	return 0;
}
/* Output */
Enter two positive number to find Lowest Common Multiple:
30
20
Lcm of two number is: 60cppLCM in C plus pluslowest common multiplefor loop