#123Easy
Digit sum without loops
Time: 1 s · Memory: 256 MB
- Recursion
Statement
You are given a non-negative integer . Find the sum of its digits without loops, using recursion.
Input format
A single integer ().
Output format
A single integer — the sum of the digits of .
Examples
Input
12345
Output
15
Input
0
Output
0
Note
The last digit is , the remaining digits are . So , with the base case for . For example, . fits in a 64-bit type.
