Answer:
def recursiveDigitSum(n):
if n<10:
return n
else:
return (n%10)+recursiveDigitSum(n/10)
print(recursiveDigitSum(93))
Explanation:
- Inside the recursiveDigitSum function, use an if condition to check whether the given number is less than 10.
- If it's true, return the number as this will act as a stopping criteria.
- Otherwise, keep on calling the recursiveDigitSum function recursively.
- Lastly call the recursiveDigitSum function.