solulubeta
Sign in
Recursion & Memo / See it, then write it
01.07 · Problem

Sum of Digits

Easy Shrink by n / 10 Pro

Return the sum of the digits of n. Use recursion, no loops.

Examples

Example 1

Input:  n = 4096
Output: 19

4 + 0 + 9 + 6 = 19.

solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 10 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 7 of 44 · updated 2026-10-13