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

NEGATIVE FEEDBACK of enzymes Activity​
When multiplying 602.4 m by 3.72 m, which value determines the number of significant figures in the answer? Explain.
What is the range of the function on the graph all real numbers all real numbers less than or equal to 1 all real numbers less than or equal to 3 all real numbe
According to his report, who believed Columbus was a god? A. The members of his family B. The native people on the islands C. The king of Spain D. The sailors o
A female parrot that weighs 13.44 ounces has a chick that weighs 0.56 ounces. How many times the chick's weight is the weight of the mother? PLEASE HELPP
Development of human resource develops the nation' Justify it​
Which words or words show that the author is giving a definition A: are called B: the most C:however D:differently
Which is an example of a polymer?
3(X + 9) + 2 = 3X + 32
Predict the next three numbers in the pattern. ​, ​, ​, ​, ​, ​, 112 nothing​, 224 nothing​, 448 nothing