You are viewing a single comment's thread. Return to all comments →
TypeScript
function superDigit(n: string, k: number): number { let sum = 0; for (let char of n) { sum += Number(char); } sum *= k; if (sum <= 9) return sum; return superDigit(String(sum), 1); }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
TypeScript