lcm and gcd

lcm and gcd

lcm is the least (least) common multiple

int lcm(int a, int b){
    
    
    if(b==1) return a;
    return a*b/gcd(a,b);
}

gcd is the greatest common divisor

int gcd(int a, int b){
    
    
    if(b==0) return a;
    return gcd(b,a%b);
}

Guess you like

Origin blog.csdn.net/weixin_51198300/article/details/115048949
gcd