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

If PQ = 21 cm and QR = 5, then what are the possible lengths for PR so that PQ,QR and PR can form a triangle? Explain your reasoning
The only way to enhance performance—scholastic, athletic, or otherwise—is to
Which religion has a personal wirship after a bath?
Explain the significance of the word "bond" to this era of United States 5.
The lowest elevation in the world is in the Dead Sea at 413 feet below sea level. The highest elevation in the world is Mount Everest at 29,035 feet above sea l
What are the levels of organization from smallest to largest?
A person who interposes habitually is most likely to be called a a. bully c. scaredy cat b. meddler
A dictionary of synonyms and antonyms is called a(n)_____. annotated dictionary abridge dictionary thesaurus
How to you get 104 using the numbers 2 3 5 8
What is parliamentary democracy in your own words?? I don't accept answers from other websites.