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

Put brackets in the expression below so that it's value is 45.024. 1.6 + 3.8 * 2.4 *4.2 (*= times )
Explain why the current is reduced as electrons move through a conductor.
what is the answer to this question -√(12)+5√(75)
Yolanda owns 4 rabbits. She expects the number of rabbits to double every year.a) after how many years will she have 64 rabbits?b) write and equation to model t
Explain why the current is reduced as electrons move through a conductor.
Factor completely, the expression: 2x^3-2x^2-12x
What is the electron configuration of helium
Locate the gerund and identify its use.Wrestling alligators seems both foolish and dangerous.
How is carbon dioxide obtained?
What is a tonal collage? We learnt it in school BUT  I can't remember.