title: Convert loop into mathematical equation
body: <p>How would I represent this for loop in a mathematical equation?</p>
  
  <pre><code>double n = 1;
      double x = Math.pow(3, n);
      for(double i = 0; i &lt; n; i++){
          x = x + Math.pow(3, i);
      }
  </code></pre>
  
  <p>Sorry wrote it in Java in a hurry.</p>