Created
October 13, 2017 21:05
-
-
Save KimSarabia/7834ae0ec4b6509032b10aca1036da55 to your computer and use it in GitHub Desktop.
Greatest Common Denominator in JavaScript
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
function gcd(a,b){if(b===0) return a; return gcd(b,a%b)} | |
// ES6 | |
let gcd = (a,b) => (b===0) ? a : gcd(b,a%b) | |
// Original: Java | |
// public int GCD(int a, int b) { | |
// if (b==0) return a; | |
// return GCD(b,a%b); | |
// } | |
// public int GCD(int a, int b) { return b==0 ? a : GCD(b, a%b); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment