/*辗转相除法:辗转相除法是求两个自然数的最大公约数的一种方法,也叫欧几里德算法。
例如,求(319,377):
∵ 319÷377=0(余319)
∴(319,377)=(377,319);
∵ 377÷319=1(余58)
∴(377,319)=(319,58);
∵ 319÷58=5(余29)
∴ (319,58)=(58,29);
∵ 58÷29=2(余0)
∴ (58,29)= 29;
∴ (319,377)=29。
可以写成右边的格式。
*/
#include<stdio.h>
int MaxCommonFactor( int a, int b)
{
int c;
if(a<=0||b<=0)
return -1;
while(b!=0)
{
c=a%b;
a=b;
b=c;
}
return a;
}
int main(void)
{
/*********Begin*********/
int a,b,c,d;
scanf("%d,%d",&a,&b);
if(a<b)
{
c=a;
a=b;
b=c;
}
while(b!=0)
{
d=a%b;
a=b;
b=d;
}
printf("%d\n",a);
/*********End**********/
return 0;
}