let getSmallestDivisor = (n, i = 2) => n % i === 0 ? i : i > Math.sqrt(n) ? 1 : getSmallestDivisor(n, i + 1); alert([ getSmallestDivisor(167), getSmallestDivisor(168), getSmallestDivisor(169) ]);