You are viewing a single comment's thread. Return to all comments →
C++
int superDigit(string n, int k) { if(n.length() == 1 && k == 1) return n[0] - 48; long sumN = 0; for(int i=0; i<n.length(); i++){ sumN += n[i] - 48; } sumN *= k; return superDigit(to_string(sumN), 1); }
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 →
C++