Counting the number of set bits in a number
<p>The problem statement is: </p>

<p>Write an efficient program to count number of 1s in binary representation of an integer.</p>

<p>I found a post on this problem <a href="http://www.geeksforgeeks.org/count-set-bits-in-an-integer/" rel="nofollow">here</a> which outlines multiple solutions which run in log(n) time including Brian Kernigan's algorithm and the gcc <code>__builtin_popcount()</code> method.</p>

<p>One solution that wasn't mentioned was the python method: <code>bin(n).count("1")</code> 
which also achieves the same effect. Does this method also run in log n time?</p>