1 int gcd(int a,int b) 2 { 3 while(b>0) 4 { 5 int c=a%b; 6 a=b; 7 b=c; 8 } 9 return a; 10 }
1 int gcd(int a,int b) 2 { 3 return b?gcd(b,a%b):a; 4 }