Skip to content

Instantly share code, notes, and snippets.

@ArunHub
Created December 27, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArunHub/e750eac7a0e44cea33668c6c51306b3e to your computer and use it in GitHub Desktop.
Save ArunHub/e750eac7a0e44cea33668c6c51306b3e to your computer and use it in GitHub Desktop.
Math.gcd = function () {
var d = Math.min.apply(Math, arguments);
for (let n = arguments.length, i = 0; d > 1 && n > i; arguments[i] % d === 0 ? i++ : (d--, i = 0));
return d;
}
console.log(Math.gcd(20, 30, 15, 70, 40));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment