function smallestCommons(arr) { const [min, max] = arr.sort((a, b) => a - b); const range = Array(max - min + 1) .fill(0) .map((_, i) => i + min); const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b)); const lcm = (a, b) => (a * b) / gcd(a, b); return range.reduce((mul, cur) => lcm(mul, cur)); } console.log(smallestCommons([2, 10]));