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, 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
Get step-by-step solutions from verified subject matter experts
