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