Question
Calculate the sum of divisors of an integer Write a function called calcDivs, which accepts one integer as parameter and returns the sum of all
Calculate the sum of divisors of an integer Write a function called calcDivs, which accepts one integer as parameter and returns the sum of all the divisors in that number. Note: The divisors of 6 are 1, 2, 3, 6, so the sum is 1 + 2 + 3 + 6 = 12. For negative numbers treat them as positive, so the sum of the divisors of 6 and -6 should be the same! Write a program to ask the user to enter how many numbers they would like to process and read that number. Then for each number that is entered invoke calcDivs and print the result from the function. Finally print a message that all numbers have been processed. Sample input/output of your program: Please enter how many numbers you would like to enter: 4 Please enter a number: 0 0 Please enter a number: 145 180 Please enter a number: -145 180 Please enter a number: 9 13 All 4 numbers were processed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started