Check if permutation of first N natural numbers exists having Bitwise AND of adjacent elements non | C ++ Program to implement the above approach ; Function to check if a permutation of first N natural numbers exist with Bitwise AND of adjacent elements not equal to 0 ; If n is a power of 2 ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void check ( int n ) { if ( ( n & n - 1 ) != 0 ) cout << " YES " << endl ; else cout << " NO " << endl ; } int main ( ) { int n = 5 ; check ( n ) ; return 0 ; }