Saturday, June 14, 2014

GCD / HCF

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);
}

No comments:

Post a Comment