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

The sum of three different numbers is 18. If every number is a prime number, what are the three numbers?
The rectangular solid has a mass of 3,300 grams. What is the density of the substance? with the sides of the cube being 50 cm, 10 cm 30 cm 0.22 g/cm 3 4.5 g/cm
which of the ordered pairs in the form (xy) is a solution of this equation? 6x - y/2 =14 (-9, 3), (2, - 4) A. Neither is a solution в. The first is not a soluti
Which of the following statements about Truman's fair deal is true ?
Is oxygen a product of cellular respiration?
Ten less than double a number is the same as seven times the number. Find the number
what is 350 over 100 in simplest form
how can a levee help prevent flooding
write the expressions in standard form 1/8(2x+4)
FRACTIONS: 1 WHOLE MINUS 7/12 MINUS 1/4