#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
int fun(int a,int b)
{
if(a>b)
{
if(a%b==0)
return b;
else
return fun(b,a%b);
}
else if(a==b)
return b;
else
{
if(b%a==0)
return a;
else
return fun(a,b%a);
}
}
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<fun(a,b)<<endl;
}
return 0;
}
递归之辗转相除法
最新推荐文章于 2023-07-27 16:08:25 发布