Print all distinct even and odd prefix Bitwise XORs of first N natural numbers | Print all distinct even & odd prefix Bitwise XORs from 1 to N ; Print the even number ; Print the odd number ; Driver Code
def evenOddBitwiseXOR ( N ) : NEW_LINE INDENT print ( " Even : ▁ " , 0 , end = " ▁ " ) NEW_LINE for i in range ( 4 , N + 1 , 4 ) : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT print ( ) NEW_LINE print ( " Odd : ▁ " , 1 , end = " ▁ " ) NEW_LINE for i in range ( 4 , N + 1 , 4 ) : NEW_LINE INDENT print ( i - 1 , end = " ▁ " ) NEW_LINE DEDENT if ( N % 4 == 2 ) : NEW_LINE INDENT print ( N + 1 ) NEW_LINE DEDENT elif ( N % 4 == 3 ) : NEW_LINE INDENT print ( N ) NEW_LINE DEDENT DEDENT N = 6 NEW_LINE evenOddBitwiseXOR ( N ) NEW_LINE