You are viewing a single comment's thread. Return to all comments →
Javascript
function superDigit(n, k) { if(n.length == 1){ return n; } else { let sum = getSum(n) * k; sum = sum.toString(); return superDigit(sum, 1); } } function getSum(n) { return n.split('').map(el => parseInt(el)).reduce((acc, curr) => acc + curr, 0); }
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 →
Javascript