title: What is the time complexity of my function?
body: <p>Started studying about complexity, I'm struggling with this one:</p>
  
  <pre><code>void what(int n) {
      int i;
      for (i = 1; i &lt;= n; i++) {
          int x = n;
          while (x &gt; 0)
              x -= i;
      }
  }
  </code></pre>
  
  <p>Well, the first for loop is clearly <code>O(n)</code>. The first iteration is <code>O(n)</code>, second one is <code>O(n/2)</code>.. and like that <code>log(n)</code> times I guess?
  Which means <strong><code>O(n) * O(log(n)) = O(n * log(n)) complexity</code></strong>. Did I get this right?</p>
  
  <p>Edit: (not a duplicate) I know what Big O is. I've asked the correct evaluation in a specific case. </p>