求最大GCD

(一)
 
 
int GCD(int a, int b){
     return b?GCD(b, a%b):a;
 }
(二)
/* 迭代法(递推法):欧几里得算法,计算最大公约数 */
int gcd(int m, int n)
{
    while(m>0)
    {
        int c = n % m;
        n = m;
        m = c;
    }
    return n;
}

猜你喜欢

转载自blog.csdn.net/qq_38122218/article/details/80368536
今日推荐