Count ways to represent N as XOR of distinct integers not exceeding N | java program for the above approach ; Function to count number of ways to represent N as the Bitwise XOR of distinct integers ; Count number of subsets using above - mentioned formula ; Print the resultant count ; Driver Code
import java . io . * ; class GFG { static void countXorPartition ( int N ) { double a = Math . pow ( 2 , ( int ) ( N - Math . log ( N + 1 ) / Math . log ( 2 ) ) ) ; System . out . print ( a ) ; } public static void main ( String [ ] args ) { int N = 5 ; countXorPartition ( N ) ; } }