Check if permutation of first N natural numbers exists having Bitwise AND of adjacent elements non | Java 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
import java . util . * ; class solution { static void check ( int n ) { if ( ( n & n - 1 ) != 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String args [ ] ) { int n = 5 ; check ( n ) ; } }