• + 0 comments

    JS

    function bitwiseAnd(N, K) {
        var max = 0;
        for (var i = 1; i <= N; i++) {
            for (var j = i + 1; j <= N; j++) {
                var t = i & j;
                if (t > max && t < K) {
                    max = t;
                }
            }
        }
        return max;
    }