Created
December 5, 2016 20:48
-
-
Save Fohlen/aa0f529bc1546841b7c520fc6737fdef to your computer and use it in GitHub Desktop.
Greatest common divisor
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
/** | |
* Returns the greatest common divisor of a and b | |
* @param {number} a | |
* @param {number} b | |
* @returns {number} | |
*/ | |
function gcd(a, b) { | |
if (b == 0) { | |
return a; | |
} else { | |
return gcd(b, a % b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment