Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/rekursiya-raqamlar-yigindisi

Sum of digits

Easy 1000 ms 64 MB 23%
Share

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)$.

Each call splits off the last digit of the number, and the split-off digits are added up

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

Sign in to submit a solution

Signing up is free and takes a minute.