Recursive Sum of Digits

You are asked to create a recursive function to calculate the sum of all the digits of a given positive integer n.
The only line of the input contains a positive integer n.
The function should return a single integer - the sum of the digits of the input number n.
Input
Output
1234
10
4567
22
999
27
Note: The function should use recursion, meaning the function should call itself to solve the problem. It should not use any loops like for or while.

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue