Skip to content

Instantly share code, notes, and snippets.

@vikaspotluri123
Last active January 30, 2018 04:15
Show Gist options
  • Save vikaspotluri123/d0302e9373343be4b6e96b3ce737d711 to your computer and use it in GitHub Desktop.
Save vikaspotluri123/d0302e9373343be4b6e96b3ce737d711 to your computer and use it in GitHub Desktop.
Greatest Common Denominator
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