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
< ? php function calculate ( $ X ) { $ number_of_bits = 8 ; return ( ( 1 << $ number_of_bits ) - 1 ) ^ $ X ; } $ X = 4 ; echo " Required ▁ Number ▁ is ▁ : ▁ " . calculate ( $ X ) . " STRNEWLINE " ; ? >