Created
November 13, 2014 13:22
-
-
Save anuradhawick/bc4baef963dce591a1f2 to your computer and use it in GitHub Desktop.
GCD/ HCF/ highest common factor for two numbers recursive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gcd(int a,int b){ | |
if (a>b){ | |
if(b==0){ | |
return a; | |
} | |
else{ | |
return gcd(b,a%b); | |
} | |
} | |
else{ | |
if(a==0){ | |
return b; | |
} | |
else{ | |
return gcd(a,b%a); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment