You are viewing a single comment's thread. Return to all comments →
My TypeScript code. Tried to shorten it but still kinda messy. Feedbacks are welcome.
function superDigit(n: string, k: number): number { const sdFunc = (str : string) => { while (str.length > 1) str = str .split('') .map(char => parseInt(char)) .reduce((s: number, a) => { return s + a }) .toString(); return str; } return parseInt(sdFunc( (k*parseInt(sdFunc(n))).toString() )); }
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 →
My TypeScript code. Tried to shorten it but still kinda messy. Feedbacks are welcome.