int gcd(int a,int b){
int max = a;
int min = b;
int temp = 0;
int result ;
//找出一个数与另一个中的大者
if (max < min) {
temp = max;
max = min;
min = temp;
}
//取余为0 则该数是最大公约数
result = max % min;
if (result == 0) {
temp = min;
}else{
temp = min ;
while (temp >1) {
temp --;
result = (min % temp) || (max % temp);
if (result == 0) {
break;
}
}
}
return temp;
}
//辗转相除法
int gcd2(int a, int b){
int t = 0;
while(b)
{
t = a%b;
a = b;
b = t;
}
return a;
}