You are viewing a single comment's thread. Return to all comments →
C++ solution
int superDigit(string n, int k) { long long sum = 0; for(char chr : n) sum += chr - '0'; sum *=k; while (sum>9){ long long sum2 =0; while (sum > 0){ sum2 += sum % 10; sum = sum/10; } sum = sum2; } return sum; }
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