辗转相除法(求最大公约数)
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;
}