You are viewing a single comment's thread. Return to all comments →
const sumDigits = (n) => String(n).split('').reduce((acc, cur) => acc + Number(cur), 0) function superDigit(n, k) { if (n < 10) { const value = sumDigits(n * k) const output = value < 10 ? value : superDigit(value, 1) return output } else { const step = sumDigits(n) return superDigit(step, k) } }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →