title: How to perform loop condition for a series based on previous term?
body: <p>For instance I got a function of y = x + 1 goes under an iteration, how am I able to make the program to stop when the relative value is less than a value let say 0.0001. The relative value is defined as,</p>
  
  <p>when x=1, y=2 ; x=2, y=3; x=3, y=4; so on and so forth. Then,</p>
  
  <p>relative value of y (when x=2) = (3-2)/3 = 0.333333</p>
  
  <p>This process is repeating until the relative value is less than 0.0001.</p>
  
  <p>The problem now is how can I defined the current y value and the previous y value so that I could put it the loop condition something like </p>
  
  <pre><code>x = input('enter initial value of x');
  while abs((current y-previous y)/current y) &lt; 0.0001
  y = 1 + x
  end
  </code></pre>