Question: (10 points) Write a function digSum(n), which takes a positive int, n, and returns the sum of the digits of n. For example the digit

 (10 points) Write a function digSum(n), which takes a positive int,

(10 points) Write a function digSum(n), which takes a positive int, n, and returns the sum of the digits of n. For example the digit sum of 125 is 1+2 +5=8. (Hint: If n is changed to a string, you can traverse the string with a for loop.)

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!