Question: Implement a recursive python function digit_sum(n) to calculate the sum of all digits of the given non-negative integer n. Then, implement a recursive python function
Implement a recursive python function digit_sum(n) to calculate the sum of all digits of the given non-negative integer n. Then, implement a recursive python function to compute the digital root digital_root(n) of the given integer n. Your function must use the digit_sum function. The digital root of a number is calculated by taking the sum of all of the digits in a number, and repeating the process with the resulting sum until only a single digit remains. For example, if you start with 1969, you must first add 1+9+6+9 to get 25. Since the value 25 has more than a single digit, you must repeat the operation to obtain 7 as a final answer. Your function digital_root(n) must use digit_sum function. Place both functions in the same file a5_part3_xxxxxx.py. Note: You can implement iterative versions of the two functions for yourself, but submit the recursive versions only. Your recursive functions must not use loops.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
