Least Common Multiple

This algorithm find the least common multiple of two integers.



									int GCD(int a, int b) {
	if (a == 0)
		return b;

	while (b != 0) {
		if (a > b)
			a -= b;
		else
			b -= a;
	}

	return a;
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}
								


Example

									int lcm = LCM(15, 12);
								


Output

									60