Dsa
Recursion
Easy
Sum of Digits Recursive
Write a program that calculates the sum of digits of a given non-negative integer using recursion. The program should return the sum of the individual digits.
Input Format:
- A single integer n (0 <= n <= 10^9).
Output Format:
- An integer representing the sum of the digits.
Example:
Input:
12345
Output:
15
Key concepts
recursiondigitssum calculation
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