Created
December 27, 2019 11:28
-
-
Save ArunHub/e750eac7a0e44cea33668c6c51306b3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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