Created
September 29, 2015 09:38
-
-
Save theanam/233427978585d1e38951 to your computer and use it in GitHub Desktop.
Euclid's algorithm for finding GCD
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
function gcd(a,b){ | |
if(a==0 || b==0){ | |
return a; | |
} | |
else{ | |
return gcd(b,a%b); | |
} | |
} | |
//test | |
console.log(gcd(10,45)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment