辗转相除法(求最大公约数)

2018-02-09  本文已影响31人  linbj
- (int)maxCommonDivisor:(int)numberA numberB:(int)numberB {
    int temp;
    while (numberA % numberB > 0) {
        temp    = numberA % numberB;
        numberA = numberB;
        numberB = temp;
    }
    return numberB;
}
上一篇下一篇

猜你喜欢

热点阅读