Maximum steps to transform 0 to X with bitwise AND | Java code to find the maximum possible effort ; Function to get no . of set bits in binary representation of positive integer n ; Driver code
class GFG { static int countSetBits ( int n ) { int count = 0 ; while ( n != 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } public static void main ( String [ ] args ) { int i = 3 ; System . out . print ( countSetBits ( i ) ) ; } }