Last active
January 30, 2018 04:15
-
-
Save vikaspotluri123/d0302e9373343be4b6e96b3ce737d711 to your computer and use it in GitHub Desktop.
Greatest Common Denominator
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
let a = 30030 | |
let b = 257 | |
const simplify = (a,b) => ({a: b%a, b: a}); | |
if(a > b) { | |
let t = a; | |
a = b; | |
b = t; | |
} | |
while(b % a != 0) { | |
console.log(b,a); | |
let i = simplify(a,b); | |
a = i.a; | |
b = i.b; | |
} | |
console.log(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment