Minimum count of consecutive integers till N whose bitwise AND is 0 with N | Java program for the above approach ; Function to count the minimum count of integers such that bitwise AND of that many consecutive elements is equal to 0 ; Stores the binary representation of N ; Stores the MSB bit ; Stores the count of numbers ; Return res ; Driver Code ; Given Input ; Function Call
class GFG { static int count ( int N ) { String a = Integer . toBinaryString ( N ) ; int m = a . length ( ) - 1 ; int res = ( int ) ( N - ( Math . pow ( 2 , m ) - 1 ) ) ; return res ; } public static void main ( String [ ] args ) { int N = 18 ; System . out . println ( count ( N ) ) ; } }