Recursion
Recursion-04
Recursion-05
Recursion-06
~/algor $ cat problems/rekursiya-raqamlar-yigindisi
Sum of digits
Easy
1000 ms
64 MB
23%
You are given a positive integer $n$. Using a recursive function, compute the sum of all its digits.
Base case: if $n < 10$, the answer is $n$ itself. Otherwise the last digit $(n \pmod{10})$ is added to the digit sum of the rest $(n \mathbin{/} 10)$.
Input
One line with a positive integer $n$ ($1 \le n \le 10^9$).
Output
The sum of the digits of $n$.
Note
$1 \le n \le 10^9$
Examples
Input #1
123
Output #1
6
Input #2
2026
Output #2
10