#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int m,int n)
{
if(max(m,n)%min(m,n)==0)
{
return min(m,n);
}
else
{
gcd(max(m,n)%min(m,n),min(m,n));
}
}
int main()
{
int m,n;
cin>>m>>n;
cout<<gcd(m,n);
return 0;
}
#include<algorithm>
using namespace std;
int gcd(int m,int n)
{
if(max(m,n)%min(m,n)==0)
{
return min(m,n);
}
else
{
gcd(max(m,n)%min(m,n),min(m,n));
}
}
int main()
{
int m,n;
cin>>m>>n;
cout<<gcd(m,n);
return 0;
}
Comments
Post a Comment