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
|
558 Discussions
|
Please Login in order to post a comment
java
There was no need of recursion, after the first sum, the remaining part can be done in constant time: => we get TotalSum = (k*sum) = x > 9 then we need an int y such that y = TotalSum/9 => SuperDigit = TotalSum - 9*TotalSum ; which will always be less than 9 and is the correct answer.
Also note that if during each next digit sum; if sum > 9 then the total digit sum = sum - 9: Please check code below
python3!!
javascript
can someone please tell me what's wrong with my code?