human
Sum of numbers with exactly 2 bits set | To count number of set bits.
To calculate sum of numbers.
To count sum of number whose 2 bit are set.
Driver code"
Solution in Python:
 Write me a code to sum of numbers with exactly 2 bits set and the other steps required?
assistant
#Here is code to sum of numbers with exactly 2 bits set and the other steps required.
 def countSetBits ( n ) :
	count = 0
	while ( n ) :
		n = n & ( n - 1 )
		count = count + 1
	return count
def findSum ( n ) :
	sum = 0
	for i in range ( 1 , n + 1 ) :
		if ( countSetBits ( i ) == 2 ) :
			sum = sum + i
	return sum
n = 10
print ( findSum ( n ) )