Maximize the largest number K such that bitwise and of K till N is 0 | C ++ program for above approach ; Function to find maximum value of k which makes bitwise AND zero . ; Finding the power less than N ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findMaxK ( int N ) { int p = log2 ( N ) ; return pow ( 2 , p ) ; } int main ( ) { int N = 5 ; cout << findMaxK ( N ) - 1 << endl ; return 0 ; }