Find the best solutions to your problems with the help of IDNLearn.com's expert users. Join our interactive Q&A platform to receive prompt and accurate responses from experienced professionals in various fields.

i need some help with this


Java programing


I Need Some Help With This Java Programing class=

Sagot :

def digit_sum(number):

 sumOfDigits = 0

 while number > 0:

     sumOfDigits += number % 10

     number = number // 10

 return sumOfDigits

or you can use,

In [2]: digit_sum(10)

Out[2]: 1

In [3]: digit_sum(434)

Out[3]: 11

or you can use,

digits = "12345678901234567890"

digit_sum = sum(map(int, digits))

print("The equation is: ", '+'.join(digits))

print("The sum is:", digit_sum)

Have a great day <3