Greatest common divisor
int gcd(int a, int b)
{
return !b ? a : gcd(b, a%b);
}
The least common multiple
Provided positive integers a and b is the greatest common divisor d, least common multiple is c, then c = a * b / d,In order to prevent overflow, Should be written as a / d * b.