Recursive calculation of the sum of digits of a number
C++
Easy
recursion
Task «Recursive calculation of the sum of digits of a number»
Write a recursive function that takes a non-negative integer and returns the sum of its digits. Use recursion, not loops. It is guaranteed that the number fits into the int type.
Input Format
Non-negative integer N (0 ≤ N ≤ 10^9).
Output Format
An integer — the sum of the digits of the number N.
Examples
Example 1
INPUT
123
OUTPUT
6
Example 2
INPUT
0
OUTPUT
0
main.cpp