ImLittleNugget
ImLittleNugget ImLittleNugget
  • 01-04-2021
  • Engineering
contestada

i need some help with this


Java programing

i need some help with this Java programing class=

Respuesta :

zayeb27
zayeb27 zayeb27
  • 01-04-2021

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

Answer Link

Otras preguntas

write a folktale that you have heard or read. ​
What was the result of the construction of the transcontinental railroad after the civil war
A friend is calling his sister from his parents’ house to talk to her about what means of transportation various people are using to come visit their parents to
The tax rate in a certain city is 10.25% Arnold makes a $310.50 purchase there. How much will Arnold pay in tax? How much will he pay in all? Tax: $______Total:
भौगोलिक विशेषताहले अर्थतन्त्र मा कसरी प्रभाव पार्दछ​​
We have learnt English _______ 2001 A. since B. in C. for D. during
x^2+y^2≤ 4y, x^2+y^2≤4x
find the surface area
Find the value of x
which of the following portions are true A. 20/48 = 40/90 B. 25/40 = 48/80 C. 18/48 = 27/72 D. 12/15 = 21/25