Answer

  1. The loop needs to maintain a running sum that will eventually be the result of the summation. Each time through the loop, then, we need to add more one more term of the summation into this running sum.
  2. The loop needs to run n times, where n is the limit of the summation. The first time through we need to add 1/2 to the sum, the next time 1/4, the next time 1/6, and so on until we add 1/2n.

Return to lesson.



Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah