title: Approximate an infinite sum within some epsilon
body: <p>I have very little experience in coding and I'm learning Python for a class. I'm being asked to approximate an infinite sum within some desired epsilon such that the difference between two consecutive terms in the series is less than epsilon. </p>
  
  <p>I searched around a little and found out about <code>'while'</code> which from my understanding can be used to create an infinite loop. I tried to get an understanding of how it worked and wrote the following:</p>
  
  <pre><code>def S(eps):
      z = 1
      S = 0
      while z == 1:
          S = S + (?)
          if S[i] - S[i-1] &lt; eps:
              z = 2
       return z
  </code></pre>
  
  <p>Assuming that'll work to break the loop, the part I'm getting stuck on is trying to define the loop that'll do the actual summation. Whenever I've made a finite loop, I usually do something along the lines of:</p>
  
  <pre><code>for i in range(n):
      S = S + whatever[i] 
  </code></pre>
  
  <p>where n would be some finite value I've defined somehow. In my problem I don't know what <code>n</code> will correspond to the epsilon I need, so I can't assign an n. I don't know any other way to make a loop though. </p>
  
  <p>Could someone please shed some light on what I can do here? </p>
  
  <p>If it matters, the sum I'm trying to do is <code>(1/k)^3</code>.</p>