Sum of DigitsEasy

Sum of Digits

EasyPractice library · +10 XPrecursionarithmetic

Write a recursive function that takes a non-negative integer N as input and returns the sum of its digits. For example, the sum of digits of 123 is 1 + 2 + 3 = 6.

Input

A single non-negative integer N.

Output

A single integer representing the sum of the digits of N.

Constraints

0 <= N <= 10^9

Time limit 1 s (native code; slower languages get more)Memory 256 MB12 hidden tests

Example 1

Input
123
Output
6

The sum of digits of 123 is 1 + 2 + 3 = 6.

Example 2

Input
90
Output
9

The sum of digits of 90 is 9 + 0 = 9.

Hints