title: worst case running time calculation
body: <p>It's from homework, but I'm asking for a general method.</p>
  
  <p>Calculate the following code's worst case running time.</p>
  
  <pre><code>int sum = 0;
  for (int i = 0; i*i &lt; N; i++)
      for (int j = 0; j &lt; i*i; j++)
          sum++;
  </code></pre>
  
  <p>the answer is N^3/2, could anyone help me through this?</p>
  
  <p>Is there a general way to calculate this?</p>
  
  <pre><code>This is what I thought:
  
  when i = 0, sum++ will be called 0 time
  when i = 1, sum++ will be called 1 time
  when i = 2, sum++ will be called 4 times
  ...
  when i = i, sum++ will be called i^2 times
  
  so the worst time will be
  0 + 1 + 4 + 9 + 16 + ... + i^2
  </code></pre>
  
  <p>but what next?? I'm lost here...</p>