Question: Write a recursive function in Python to find the sum of digits of a number. Name the function sum_of_digits. The function should use recursive algorithm
Write a recursive function in Python to find the sum of digits of a number. Name the function sum_of_digits. The function should use recursive algorithm (calling itself). The function should print out the sum of all the digits of a given number. For example, sum_of_digits(343) should have a output of 10. Marks will be deducted if you do not follow strictly to the instructions.
[3]: N 1 def sum_of_digits(n): HNM in sum_of_digits (343) Out[3]: 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
