The following is a simple yet efficient recursive code to calculate the GCD of 2 numbers.
Euler Method
#define LL long long int
LL gcd(LL a, LL b)
{
if(a==0)return b;
else return gcd(b%a,a);
}
Euler Method
#define LL long long int
LL gcd(LL a, LL b)
{
if(a==0)return b;
else return gcd(b%a,a);
}
No comments:
Post a Comment