i need some help with this


Java programing

I Need Some Help With This Java Programing

Answers

Answer 1

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


Related Questions

Other Questions
A classroom had 35 glue sticks.If the ratio of glue sticks to glue bottles was 5:2 how many glue bottles did the classroom have NEED HELP WILL GIVE 10 POINTS NEED IT NOW AND CORRECT PLSSS TYSMWhat two types of government are the best examples of autocracy? An oligarchy and representative democracy A Representative democracy and communism A republic and monarchy A dictatorship and monarchy Which graph represents the conic 4x2 16x 9y2 + 54y 101 = 0?It is the forth graph. ways in which landscape can be created .plz answer this PLEASE I NEED HELP CLICK ON THIS IMAGE Which of the following is a neutralization reaction? aSiCl4 + 4 H2O H4SiO4 + 4 HC bHCl + NaOH NaCl + H2O c6 CO2 + 6 H2O C6H12O6 + 6 O2 d2Al + 6HCl 2AlCl3 + 3H2 How were many Italians Introduced to Brazil after slavery ended?*They worked as merchants in commerce*they worked on coffee plantations*They worked primarily as nuns and priests in the Roman Catholic Church*they Introduced ranching to Brazil HELP PLS THIS IS DUE TODAY (I WILL BE MARKING BRAINLIEST) one number is nine than another number. if the sum of the numbers is 65, find both numbers. ASAP will give brainliest Question 3(Multiple Choice Worth 5 points)[06.04 MC]How did people in the North use natural resources differently than people in the South?They were more industrial, while Slytherners were more agricultural.They protected their natural resources better than the Southerners.They used their own natural resources to run their factories and farms.They were more agricultural, while Southerners were more industrial, French help!!- Fort Caroline- J.J. Audubon - Jean Bart - Martinique - Pointe-Noire- les Saintes - Saint-Barthlemy- Saint-Domingue In this simulation, theoretical utilization of the intensive care unit (ICU) is calculated as the flow rate of patients that arrive for service at the ICU in a given unit of time divided by the ICUs capacity to serve customers in that same unit of time. You can think about this as demand/capacity. What is the theoretical utilization of the ICU if the mean inter-arrival time is 4 hour(s), the mean length of stay is 6 hour(s), and there are 4 beds in the ICU? It is estimated that 78% of drivers use their turn signal. Part A: What is the probability that exactly 3 drivers use their turn signal if a police officer pulls over five drivers? (5 points) Part B: What is the probability the next driver using their turn signal that the police officer pulls over if the fifth driver? (5 points) (10 points) Fill in the blanks with suitable pronoun. (5 marks)1. She is Aminah. Aminah is _________ name.2. Nobody took her there. _______ went there by __________.3. I can go to work by ________ every day.4. She give a pen to you. The pen is _________.5. They hid _______ under the bed yesterday.Write the correct adjective for each sentence in the blank space given. (5 marks)1.Dont go near the dog. It is ____________ (dangerous/ dangerouser/ most dangerous).2.Samy always wakes up __________ (early/ earlier/ more early) than his brother, Rama.3.Swee Boon young; but he is ________ (stronger/ strongest/ strong) than his father.4.Lisa was the ____________ (successful/ more successful/ most successful) student in her class.5.The sky is __________ (cloudier/ cloudy/ more cloudy). It is going to rain.Fill in the blanks with the correct tense form (simple present/simple past/simple future) of the verbs in brackets. (10 marks)1.I __________ (not,be) here next week.2.___________ (be) he here yesterday?3.My father ___________ (pay) the bills tomorrow.4.Mrs. Sufiah ___________ (have) a lot of friends when she was a teenager.5.Cooking oil ___________ (be) a must for frying.6.I always ___________ (close) the window at night because it is cold.7.The athletes ____does_______ (do) their best to win the games tomorrow.8.Last night, Linda ___________ (arrive) home very late.9.___________ she ___________ (have) any class today?10.___________ the small boy ___________ (understand) what you are going to say? The process that breaks glucose into smaller parts?A. Glycolosis B. Fermentation C. Cellular respiration D. Photosynthesis The set of negative energy is greater than -7 __Is when water changes from a solid to a liquid Please help I will give brainliest The teacher wants to group 87 students into teams which have the same number of students. There must be more than one team. At least how many teams are there and how many students are there in each team? I WILL GIVE BRAINLIEST !!!What is the product of 4 and 7?7Oo8 91491478