Question: Description Write a recursive method (no loops) which takes in a non-negative integer and returns the sum of all the digits in a number. You

Description

Write a recursive method (no loops) which takes in a non-negative integer and returns the sum of all the digits in a number. You should call this method recursiveSum.

For Example: recursiveSum(126) would return 9 as 1 + 2 + 6 = 9

Input

 n, where n is a non-negative integer 

Sample Input

 126 

Output

 The sum of all single digits in a number 

Sample Output

 Result = 9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!