title: How would I calculate the runtime of this function?
body: <p>I have this function written in C++ and I am trying to calculate the runtime of it. I believe the runtime is O(n^2) (I attempt to explain why using comments in the code), but I was looking for confirmation.</p>
  
  <pre><code>    void f1(int n)
      {
      int t = sqrt(n);
        for(int i = 0; i &lt; n; i++){              //this outer for loop by itself has a runtime of O(n) but decreases by sqrt(n) every time it goes back to the top
          for(int j = 0; j &lt; n; j++){          //this inner for loop has a run time of O(n) but decreases by sqrt(n) every time it goes back to the top of the function
              // do something O(1)
          }
          n -= t;                             
        }
      }
  </code></pre>