title: Why is this function/loop O(log n) and not O(n)?
body: <p>This function is O(log(n)). Why? Isn't it looping up to n?</p>
  
  <pre><code>function fxn($n) {
      for ($i = 1; $i &lt;= $n; $i *= 2)
          echo $i;
  }
  </code></pre>
  
  <p>I'm pretty new to O(n) analysis by the way. This function sure looks O(n) though since it loops up to n.</p>