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

Neither his father nor his mother (play, plays) the game.
how many minutes do you boil eggs
what was robert brown looking at through a microscope when he found evidence of the 1827 scientific concept named in his honor?
a bluegill population is at its carrying capacity in a stable lake in minnesota. biologists studying the bluegills' reproductive behavior learn that a single fe
how many seconds in an hour
what keeps a white dwarf from contracting further?
the mobile company charges $180 for an hour of service how many dollars are customers charged every minute
what is the meaning of good friday
multinationals definition
When a pathogen, or infectious agent, invades an organism, which cells produce antibodies to fight infection? A) red blood cells