You are viewing a single comment's thread. Return to all comments →
@anirbansaha77 This recursive JavaScript solution has passed all test cases in Node.js:
function superDigit(n, k) { n = n.split("").reduce((a, b) => +a + +b) * k + ""; return (n.length > 1) ? superDigit(n, 1) : n.charAt(0); }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
@anirbansaha77 This recursive JavaScript solution has passed all test cases in Node.js:
JavaScript Solution (with Recursion)