Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Discover a wealth of knowledge from professionals across various disciplines on our user-friendly Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

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