Count of integers K in range [ 0 , N ] such that ( K XOR K + 1 ) equals ( K + 2 XOR K + 3 ) | C ++ program for the above approach ; Function to count all the integers less than N satisfying the given condition ; Store the count of even numbers less than N + 1 ; Return the count ; Driver Code ; Given Input ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countXor ( int N ) { int cnt = N / 2 + 1 ; return cnt ; } int main ( ) { int N = 4 ; cout << countXor ( N ) ; return 0 ; }