Find a value whose XOR with given number is maximum | Function To Calculate Answer ; Find number of bits in the given integer ; XOR the given integer with poe ( 2 , number_of_bits - 1 and print the result ; Driver Code
def calculate ( X ) : NEW_LINE INDENT number_of_bits = 8 NEW_LINE return ( ( 1 << number_of_bits ) - 1 ) ^ X NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT X = 4 NEW_LINE print ( " Required ▁ Number ▁ is : " , calculate ( X ) ) NEW_LINE DEDENT