#include<stdio.h>
int main()
{
int Gcd(int a,int b);
int x,y,m;
scanf("%d %d",&x,&y);
m=Gcd(x,y);
printf("%d",m);
return 0;
}
int Gcd(int a,int b)
{
int i,c;
if(a<b)
{
c=a;
a=b;
b=c;
}
for(i=b;i>0;i--)
{
if(a%i==0&&b%i==0)
{
break;
}
}
return i;
}
(2)
#include<stdio.h>
int Gcd(int a,int b);
int main()
{
int x,y,m;
scanf("%d %d",&x,&y);
m=Gcd(x,y);
printf("%d",m);
return 0;
}
int Gcd(int a,int b)
{
int r;
do
{
r = a % b;
a = b;
b = r;
}
while (r != 0);
return a;
}