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

1. Angle BAC = 35° and angle BCA = 20°. What is the measure of angle BAD? 2. What is the measure of angle ABC?
Write 22,22 as a fraccion
olde times because yes
What are the rules of trichotomy???​
a man brought 10 bags for Rs 5000. He sold 7 bags at Rs 550 wash and remaining at the rate of cost price.Find his profit percent​
In a blueprint, each square has a side length of 1/4 inch. Ceramic tile costs $5 per square foot. How much would it cost to tile the bathroom? Carpet costs $18
PROJECT MATH - ANGLE OF ELEVATION AND DEPRESSION - Guys can anyone help me of this project - I have to write a story about the picture - Then questions - Tra
5. Suppose a space ship traveling at 1000 miles per hour enters an area free of gravitational forces and free of air resistance. If the pilot wishes to slow the
(-2,y) and (2,4); slope: 1/4
The type of economy most closely associated with North Korea is a(n) A.traditional economy. B.mixed economy C.free market. D.command economy.