1.更相减损法
int gcd(int a,int b){ while(a!=b) { if(a>b) a-=b; else b-=a; } return a;}
2.辗转相除法--递归
int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}
3.辗转相除法--纯循环
int gcd(int a,int b){ int r; while(b!=0) { r=a%b; a=b; b=r; } return a;}
4.最小公倍数--穷举法
//穷举法求最小公倍数 for (i= a; ; i++ ) if ( i % a == 0 && i % b ==0 ) break; printf("The least common multiple:%d\n", i )