Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code using python using recursion the sum of its digits Write a recursive functi

ID: 3757177 • Letter: C

Question

Code using python using recursion

the sum of its digits Write a recursive function named sum_digits that takes a given a non-negative integer N and returns Hint Mod (%) by 10 gives you the rightmost digit (126 % 10 is 6), while doing integer division by 10 removes the rightmost digit (126 / 10 is 12). This function has to be recursive; you are not allowed to use loops to solve this problem! This function takes in one integer and returns one integer For example: Test Result print (234, ":", sum_digits (234))234:9 Answer: (penalty regime: 0 %)

Explanation / Answer

def sum_digits(n): if n == 0: return 0 else: return sum_digits(n//10) + (n%10)