Question: Problen Statement An integer a is a divisor of an integer b if a divides b evenly (i.e. there is no remainder when b is

Problen Statement An integer a is a divisor of an integer b if a divides b evenly (i.e. there is no remainder when b is divided by a, or in C code, when b%a -- 0). E.g., 1, 2, 3, and 6 are divisors of 6, while 4 and 5 are not. (Note that a divisor of a number must be less than or equal to that number.) A proper divisor of b is a divisor that is less than b. E.g.. only 1, 2, and 3 are proper divisors of 6. Any positive integer n may be classified into one of three categories based on the sum of all the proper divisors of n. If the sum is less than n, then n is said to be deficient. If the sum is equal to n, then n is said to be perfect. If the sum is greater than n, then n is said to be abundant. E.g., the sum of the proper divisors of 6 (1.2, and 3) is 6, so 6 is a perfect number. Assignment Write a complete program as follows: a. (25 points) Write a function compute_sum_of_proper_divisors with the following analysis and design that computes and displays the the proper divisors of a positive integer, sums them up, and returns the sum. Analysis Objects Number to find divisors for Type int int Movement received returned Name Sum of proper divisors sum . Design 1. Initialize sum to 0 2. Display output labeling 3. Count a loop control variable (lcv) from 1 to n-1 by 1 3.1. If the lcv divides n evenly then 3.1.1. Display the lcv 3.1.2. Add the lcv to the sum 4. Return the sum b. (25 points) Write a main program with the following analysis and design that repeatedly computes and displays the proper divisors of a number and determines its classification (deficient, perfect, or abundant). The program stops when the user enters 0 for the number. e Design 1. Display the program greeting 2. Ask the user for a positive integer 3. Repeat while the number is not 0 3.1. Compute the sum of proper divisors using the function you wrote for part (a) 3.2. Classify the number based on the sum of its proper divisors 3.3. Ask the user for another positive integer Display the program exit message 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
