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

Females Height Males Age Age Height 15 15 16 15 15 15 16 16 15 15 16 170 154 160 159 156 153 166 163 167 151 171 15 16 16 15 15 15 15 14 185 183 174 183 173 173
When Nepal clear-cut its mountainous forests, it created environmental disasters in other countries. Which of the following is not one of the created disasters?
ignore the crossword. please help <3
What is the tone or overall feeling the poem conveys? loneliness warmth melancholy anticipation the poem is Sestina by elizebeth bishop
(6x – 2y = 5 4x – 3y = 5
please can someone help my assignment​
Help please!! Write a story about you imagining how the future of the UAE will look like, what will be the developments that will be witnessed by the Emirates i
help meeee:eeeeeeeeee:(
Turn on Show element name. What causes the element name to change?
how do I simplify one 1 42/40