Open this example in the interactive library
Source code
const gcd = (a, b) => (b ? gcd(b, a % b) : a);
const w = 1800,
h = 1200,
d = gcd(w, h);
console.log([w / d, h / d]);
Sample output
[ 3, 2 ]

Open this example in the interactive library
const gcd = (a, b) => (b ? gcd(b, a % b) : a);
const w = 1800,
h = 1200,
d = gcd(w, h);
console.log([w / d, h / d]);
[ 3, 2 ]