View Code
1 #include<stdio.h> 2 int gcd(int x,int y) 3 { 4 int r; 5 while(y!=0) 6 { 7 r=x%y; 8 x=y; 9 y=r; 10 } 11 return x; 12 } 13 int main() 14 { 15 int a,b; 16 while(~scanf("%d%d",&a,&b)) 17 { 18 printf("%d\n",gcd(a,b)); 19 } 20 }