/*
===================== GCD (GREATEST COMMON DIVISOR) =====================
FINDING THE GREATEST COMMON DIVISOR EFFICIENTLY USING EUCLID'S FORMULA.
GCD(a,b) = GCD(b, a%b)
*/
int GCD (int a, int b){
// base case
if(b == 0)
return a;
return (b, a%b);
}
int main() {
int a = 7;
int b = 21;
cout << GCD(a,b);
return 0;
}
Last active
July 24, 2020 18:26
-
-
Save rahularity/8c9089a09e7d45d6b78229893544fc88 to your computer and use it in GitHub Desktop.
Midnight Code: learn before you sleep. (DAY 1)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment