Question: Write a recursive function named digit _ sum that accepts an integer as a parameter and returns the sum of its digits. For example, calling

Write a recursive function named digit_sum that accepts an integer as a parameter and returns the sum of its digits. For example, calling digit_sum(1729) should return 1+7+2+9, which is 19. If the number is negative, return the negation of the value. For example, calling digit_sum(-1729) should return -19.

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 Programming Questions!