Answered You can hire a professional tutor to get the answer.

QUESTION

C Programming: Assignment : an algorithms and a program to determine which of a sequence of integers is a "perfect number" and then compute the...

C Programming:

Assignment: an algorithms and a program to determine which of a sequence of integers is a "perfect number" and then compute the square root (√) of those perfect numbers. The calculation of the square root (√) will be done as the sum of an infinite series:

         ∞         

   √S = ∑ xn+1 = 1/2(xn + S/xn)

         n=0

   where x0 is the initial "guess"

See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots for details. Use only the Babylonian method (above) for your square root (√), not the C math library function.

Output: Output will include all of the perfect numbers between [1-10000], along with a list of their factors to confirm the factors sum to the number. For each perfect number, the output will also include your computed value for the square root of that number, the expected value using sqrt(), and the number of terms (iterations) it took to reach sixteen decimal-place accuracy.

Results should be displayed so as to allow easy comparison of the computed and expected values. Labels should be included, where appropriate. Your output would look something like:

  Perfect number: 6 = 1 + 2 + 3;

  Expected sqrt() of 6     = 2.4494897...

  Computed square root of 6 = 2.449489742783...

     reached in 8 iterations.

Note: output above is just an example...

Input: No user input.

Requirements

Efficiency should always be considered. Alway choose the most appropriate loop/decision structures and variable/constant types. Use of appropriate constants expected. Functions should focus on a single task and do it well - and use as many functions as dictated by your design. Main() should only be the high-level tasks.

Use allowed Standard C libraries as required - and document. You may also find DBL_EPSILON useful.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question