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

In a given country the average price of a gallon of unleaded gasoline in 1997 was $1.58 in 2010 the average price was $3.11 find and interpret the average rate
What’s the correct answer answer asap for brainlist
what do you do when you feel burned out? Any self care that you do try to create?​
100 POINTS 6 different answers needed, and a chart filled out I'll work on it on my own, but I do need some help and it would also be nice to compare my answe
In a given country the average price of a gallon of unleaded gasoline in 1997 was $1.58 in 2010 the average price was $3.11 find and interpret the average rate
What is the term for the type of venation seen on a ginkgo tree? Help meeeee
yes haha yes what no oh yeah no nevermind wait yes
how much is 409,000x509,000
pls pls help whoever gets it right gets a crown
1+0.9+0.08+0.001 Somebody can help me please