• + 0 comments

    C++

    int bitwiseAnd(int N, int K) {
       int max = 0;
        int themacneeded;
        list<int> myList;
        if ( K == 1) {
            return themaxneeded = 0;
        }
        else{
             for (int i= 2; i < N ; i++){
                 for ( int j = i +1  ; j <= N ; j++){
                     max= i & j;
                     if ( max < K  && max >= themaxneeded){
                          themaxneeded = max ;
                     }
                 }
        }
        return themaxneeded;
        }
    
    }