Count ways to represent N as XOR of distinct integers not exceeding N | Python 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
from math import * NEW_LINE def countXorPartition ( N ) : NEW_LINE INDENT a = 2 ** floor ( N - log ( N + 1 ) / log ( 2 ) ) NEW_LINE print ( int ( a ) ) NEW_LINE DEDENT N = 5 NEW_LINE countXorPartition ( N ) NEW_LINE