Simplest gcd function (a%b) approach

programming
Tags: #<Tag:0x00007f2426dc1800>

#1

int gcd1(int a,int b)
{
if(a==1||b==1)
{
return 1;
}
if(b==0)
{
return a;
}
return gcd1(b,a%b);
}

int Solution::gcd(int A, int B) {
return gcd1(A,B);
}