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 cones are similar. Find the volume of cone B. Write your answer in terms of pi.
Why does a rainforest have more biodiversity than a temperate forest? give one reason. apex?
[tex] \frac{4 + 7 \times 1 }{ - 10} [/tex]​
Read the following passage from "The Black Cat": But to-morrow I die, and to-day I would unburthen my soul. My immediate purpose is to place before the world, p
Please help me out please
What happened to Ngo Dinh Diem and his brother Nhu? They were exiled after a military coup. They were killed in a military coup. They were imprisoned in Saigon
I need help with this question please
I need help ASAP (20points)
Chlorine has two stable isotopes, Cl-35 and Cl-37. If their exact masses are 34.9689 amu and 36.9695 amu, respectively, what is the natural abundance of Cl-35?
Please please help me