You are viewing a single comment's thread. Return to all comments →
Recursive c++ solution
int superDigit(string n, int k) { if (n.size()==1) return std::stoi( n ); else{ return superDigit(to_string(accumulate(n.begin(),n.end(),uint64_t(0),[](auto a, auto b){ return a+int(b-48);})*k),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 →
Recursive c++ solution