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

Which answers describe the shape below? Check all that apply. A. Parallelogram B. Rectangle C. Square D. Rhombus E. Trapezoid F. Quadrilateral
help me pls i don't ge this
If the fixed cost is 9000 per year. Variable costs are estimated to be Tk. 60.75 / item. The firm wants to break even if 80 items are sold per year. What should
A cubical house can hold 4096m of air .find the height of the house​
She ....a shower in bathroom.(Fill in the blanks with simple present/present continuous form of the verb have
What does the imagery in this passage help readers envision? What does this imagery most clearly emphasize to readers?
Solve for x. Round to the nearest tenth, if necessary.
A theory is an explanation while a model is a representation vividly identify and describe the meeting point of the two concepts. ?
3. MOMERTIKANLIS 4. RALLIBE= LDE ZT TETAAT
Explain why the following function is not piecewise continuous ​