1// Reduce a fraction by finding the Greatest Common Divisor and dividing by it.
2function reduce(numerator,denominator){
3 var gcd = function gcd(a,b){
4 return b ? gcd(b, a%b) : a;
5 };
6 gcd = gcd(numerator,denominator);
7 return [numerator/gcd, denominator/gcd];
8}
9
10reduce(2,4);
11// [1,2]
12
13reduce(13427,3413358);
14// [463,117702]
15