title: What is the complexity of this sum algorithm?
body: <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int N = 8;  /* for example */
      int sum = 0;
      for (int i = 1; i &lt;= N; i++)
          for (int j = 1; j &lt;= i*i; j++)
              sum++;
  
      printf("Sum = %d\n", sum);
      return 0;
  }
  </code></pre>
  
  <p>for each n value (i variable), j values will be n^2.  So the complexity will be n . n^2 = n^3.  Is that correct?</p>
  
  <p>If problem becomes:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int N = 8;  /* for example */
      int sum = 0;
      for (int i = 1; i &lt;= N; i++)
          for (int j = 1; j &lt;= i*i; j++)
              for (int k = 1; k &lt;= j*j; k++)
                  sum++;
  
      printf("Sum = %d\n", sum);
      return 0;
  }
  </code></pre>
  
  <p>Then you use existing n^3 . n^2 = n^5 ?  Is that correct?</p>