Numbers whose bitwise OR and sum with N are equal | Java program to count numbers whose bitwise OR and sum with N are equal ; Function to find total 0 bit in a number ; Function to find Count of non - negative numbers less than or equal to N , whose bitwise OR and SUM with N are equal . ; count number of zero bit in N ; power of 2 to count ; Driver code
class GFG { static int CountZeroBit ( int n ) { int count = 0 ; while ( n > 0 ) { if ( ( n & 1 ) != 0 ) count ++ ; n >>= 1 ; } return count ; } static int CountORandSumEqual ( int N ) { int count = CountZeroBit ( N ) ; return ( 1 << count ) ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . print ( CountORandSumEqual ( N ) ) ; } }