Maximize the largest number K such that bitwise and of K till N is 0 | package whatever do not write package name here ; Function to find maximum value of k which makes bitwise AND zero . ; Finding the power less than N ; Driver Code
import java . io . * ; class GFG { static int findMaxK ( int N ) { int p = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) ; return ( int ) Math . pow ( 2 , p ) ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( findMaxK ( N ) - 1 ) ; } }