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.
If you're having trouble with timeouts or the last 3 cases:
Don't try to build a string of len(n) * k length or try to implement a loop over the string repeatedly - just calculate the sum of the digits of n then multiply by k
If you fail cases 5, 7, 8 after that, make sure your integer type is at least 64 bits as the values for those cases overflow 32 bit integers (even though the setup for languages like golang always want 32 bit answers)
Cookie support is required to access HackerRank
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 →
If you're having trouble with timeouts or the last 3 cases:
len(n) * k
length or try to implement a loop over the string repeatedly - just calculate the sum of the digits ofn
then multiply by k