Dsa
Recursion
Warm-up
Recursive Sum of Digits
Given a positive integer n, write a program that calculates the sum of its digits recursively. The process continues until n becomes 0. The input is a single integer n (1 <= n <= 10^9). Output the sum of the digits of n.
Example:
Input: 12345
Output: 15
Key concepts
recursiondigitssum
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now