2 ways to deal with digit_sum


But still think the digit_sum2 function seems to be too complicated.
Is there any way to make it shorter and more clearly?


digit_sum2 is very lengthy. simply declare a variable total and give it a value of zero

use a while loop to check if n is greater then zero, then use the remainder to calculate the last digit, add it total, then use floor division on the number


Thank you very much!!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.