title: Nested Loop Iteration Count
body: <p>Sorry if I'm re-asking a previous question but I can't quite find a concrete answer to this question. How can I make a formula for nested for loop iterations besides basic ones like:</p>
  
  <pre><code>for (int i =0; i &lt; N; i++)
  </code></pre>
  
  <p>I get the basic concept of count iterations of basic loops:</p>
  
  <pre><code>for (int i =0; i &lt; N; i++)
  </code></pre>
  
  <p>The boolean condition is equal to some variable (for instance N) then is subtracted from the initial variable (for instance i) then is divided by the number of loops nested (in this case 1 since it is not nested). So the number of iterations for this loop would be:</p>
  
  <pre><code>(N - i) / 1
  </code></pre>
  
  <p>For example, for finding the iterations of nested loops this would be repeated down the loops until you make it to the innermost loop then you multiple all the loops for the iteration count.</p>
  
  <p>I just don't understand more complicated loops with different increment conditions such as multiplication or division. Specifically how I can figure out how many times this loop iterates:</p>
  
  <pre><code>for (int i = 1; i &lt; 1000; i *= 2)
      for (int j = 0; j &lt; 1000; j++)
  </code></pre>
  
  <p>I know this has to do something with summation unfortunately I'm not seeing the connection. Any resources or advice would be greatly appreciated.</p>