jaimex8
2/18/2016 - 9:38 PM

Find GCD(Greatest common denominator) of fraction and reduce it

Find GCD(Greatest common denominator) of fraction and reduce it

function fractionReducing(fraction) {
  var gcd = function gcd(a,b){
    return b ? gcd(b, a%b) : a;
  };
  gcd = gcd(fraction[0],fraction[1]);
  return [fraction[0]/gcd,fraction[1]/gcd];
 }