go to previous page   go to home page   go to next page

Answer:

The numbers got too big to be represented in datatype long. This is overflow, which produces incorrect results.


Recursive Version of Result-controlled Loop

Anything that can be done with looping can be done with recursion. So there must be a recursive equivalent of any result-controlled loop. Here is one way to do this:

  1. If the current result has reached the goal, finish the computation.
  2. Otherwise, improve the result (by calling this method).

Recursion is often a natural fit to some types of problems where a preliminary result is repeatedly improved.


QUESTION 17:

Does Newton's method fit the style of repeated improvement?


go to previous page   go to home page   go to next page