辗转相除法
//非递归版
int gcd(int a,int b)
{
int t;
while(b!=0){
t=b;
b=a%b;
a=t;
}
return a;
}
//递归版
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
更相减损法
int mds(int a,int b){
while(a!=b){
if(a>b){
a=a-b;
}else{
b=b-a;
}
}
return a;
}