Objective: The goal of this assignment is to practice recursion.
Assignment. The author of a CS 2401 textbook is trying to predict a honorarium that he will earn for this book. The honorarium is proportional to the number of books sold. In the publisher's experience, this amount follows the power law: the amount of money m(n) earned in year n is equal to m(1) * n-α, where α is a parameter depending on the book. Once we know the values m(1) and m(2) = m(1) * 2-α, we can find α from the ratio m(2) / m(1) (hint: use logarithms). One the value α is determined, we now need to compute, for each year N, the total amount of money earned by this year, i.e., the sum
Write two methods that, given the values m(1), m(2), and N, predict s(N): a method based on recursion and an iterative method that uses a simple for loop; the ideas behind both methods are explained in similar examples in the class and in the book.
Once the methods are up and running, compare the speed of these two approaches by using the same techniques as in Assignment 3. Record your observations and be able to explain what is happening to your TA when you demo your program.
Testing. Do not forget to test your method. To test your method, pick any value of m(1) and α. For example, if you take m(1) = 100.0 and α = 1.0, then should get m(2) = 100.0 * 2-1 = 100.0 / 2 = 50.0, m(3) = 100.0 * 3-1 = 100.0 / 3 = 33.33..., and m(4) = 100.0 * 4-1 = 100.0 / 4 = 25.0, and thus,