Skip to content

Instantly share code, notes, and snippets.

@mindplace
Created March 23, 2016 02:40
Show Gist options
  • Select an option

  • Save mindplace/c06659bc8952ba3ffa15 to your computer and use it in GitHub Desktop.

Select an option

Save mindplace/c06659bc8952ba3ffa15 to your computer and use it in GitHub Desktop.
function euclidGreatestCommonFactor(numOne, numTwo){
if (numOne > numTwo) {
var larger = numOne;
var smaller = numTwo;
}
else {
var larger = numTwo;
var smaller = numOne;
}
var remainder = larger % smaller;
if (!(remainder === 0)) {
console.log(remainder);
return euclidGreatestCommonFactor(smaller, remainder);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment