最大公倍数_Greatest Common Divisor

计算最大公倍数

Static int gcd( int a, int b)
{
    int t;
    while( b>0)
    {
        t = b;
        b = a % b;
        a = t;
    }
    return a;
}

private static int getGCD(int a, int b)
{
    if (a == 0)
        return b;

    while (a != b)
    {
        if (a > b)
            a = a - b;
        else if (b > a)
            b = b - a;
        else
            return a;
    }
}

 

posted @ 2016-07-20 16:11  木子执手  阅读(178)  评论(0编辑  收藏  举报