求两数的最大公约数和最小公倍数
unsigned int gcd(unsigned int a, unsigned int b) { unsigned int rem; while (b != 0) { rem = a % b; a = b; b = rem; } return a; }
Euclidean辗转相除法
unsigned int lcm(unsigned int a, unsigned int b) { return a / gcd(a, b) * b; }
根据 greatest common divisor 求 least common multiple