gcd 运用辗转相处法: int gcd(a,b) { if(b) return gcd(b,a%b); else return a; } lcm 在gcd基础上稍加运算: int lcm(a,b) { return a/gcd(a,b)*b; }