Recursive Sum Digits

Recursion Math Coding

Problem Description

Write a recursive function that takes a non-negative integer and returns the sum of its digits.

For example:

  • Input: 12345
  • Output: 15

Explanation: 1 + 2 + 3 + 4 + 5 = 15

Requirements

  • You must use a recursive approach, without using loops.
  • Handle the edge case when the input is 0.
  • Assume the input is always a non-negative integer.

Bonus

In celebration of Bangladesh's Independence Day on March 26, consider how recursive thinking can elegantly break down a problem into smaller parts—much like how history is built layer by layer.