title: How is the complexity of below O(log n) and not O(n)
body: <p>Could someone explain how this algorithm is <code>O(log(n))</code> and not <code>O(n)</code>?</p>
  
  <p>the loop runs for all the digits in a given number. So isn't the           complexity <code>O(n)</code>?</p>
  
  <pre><code> while (x != 0) {
        int pop = x % 10;
        x /= 10;
        if (rev &gt; Integer.MAX_VALUE/10 || (rev == Integer.MAX_VALUE / 10 &amp;&amp; pop &gt; 7)) 
             return 0;
        if (rev &lt; Integer.MIN_VALUE/10 || (rev == Integer.MIN_VALUE / 10 &amp;&amp; pop &lt; -8)) 
             return 0;
        rev = rev * 10 + pop;
  }
  </code></pre>