We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Recursive Digit Sum
- Discussions
Recursive Digit Sum
Recursive Digit Sum
Sort by
recency
|
187 Discussions
|
Please Login in order to post a comment
C++ SOLUTION:
int superDigit(string n, int k) { //Base case. If n is a super digit and it doesn't need to be concatenated if((n.size() == 1) && (k == 1)) { return n[0] - '0'; } //We intialize rVal as a long long so that it can handle the large test cases long long rVal = 0;
}
Python 3
Seems to work fine with decimal or with System.Numerics.BigInteger, as long as the Sum is appropriately cast. I tried casting to ulong as well, but that took too long to run.
My C solution : ( the long long to array part was not my part )