Given a positive integer , find the sum of its digits. For example, if , the answer is .
You can split into: - Last digit: n % 10 - Remaining digits: n // 10 Then the sum is: last digit + sum of the rest. plaintext Input: 1234 Output: 10 Input: 9 Output: 9 Input: 100 Output: 1 Before reading the solution, identify the base case yourself. When is the answer obvious without recursion?