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

What is a similarity between the temperate climate zone and polar climate zone? A. Both climate zones get less than 100 cm of precipitation in a year. B. Both c
How much of a circle does a 100-degree angle turn through? A.1 B.100/180 C.50/360 D.100/360
a treble clef is also know as what​
Working in the middle colonies was attractive because European immigrants
I NEED HELP ASAP!!People that now the Answer help me please
Was bedeutet Rhytmus und Takt?​
Write a linear equation that goes through the points (-1,-10) and (5,2).
Use what you've learned in the lesson to develop a hypothesis about how changes in technology affect society. Describe your hypothesis and provide evidence for
Stuck on this problem
use different method of depreciation for each of the assests and explain why u used the method (ex : straight line method, double declining method, unit of prod