Skip to content

Instantly share code, notes, and snippets.

@Fohlen
Created December 5, 2016 20:48
Show Gist options
  • Save Fohlen/aa0f529bc1546841b7c520fc6737fdef to your computer and use it in GitHub Desktop.
Save Fohlen/aa0f529bc1546841b7c520fc6737fdef to your computer and use it in GitHub Desktop.
Greatest common divisor
/**
* 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