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 main goal of the Federal Reserve in its monetary policy? A) lowering taxes B) to curb recessions C) increasing government spending D) regulation of th
Where do the male and female gametes meet?
need help with this please and thank you in advance
can someone help me please
describe the organization of constitution using the words Preamble article and the amendment
what problem is described in the paragraph? wheels part 2
Function f if an exponential function.By what factor does the output value increase as each input value increases by 1?x: -1, 1, 3, 5, 7f(x): 1/4, 6, 64, 1024,
HELP ASAP 25 POINTS I worked on it nd I think this is right I just need to make sure and I’m not sure about the third blank.
how many school assemblies are required in nj? PLEASE ANSWER QUICKLY IT'S VERY IMPORTANT
When a strip of zinc metal is added to a test tube of hydrochloric acid, the liquid forms bubbles, and the test tube feels hot. The bubbles are a result of the