Maximum value of B less than A such that A ^ B = A + B | Function to find the maximum value of B such that A ^ B = A + B ; Binary Representation of A ; Loop to find the negation of the integer A ; output ; Driver Code ; Function Call
class GFG { static void maxValue ( int a ) { String c = Integer . toBinaryString ( a ) ; String b = " " ; for ( int i = 0 ; i < c . length ( ) ; i ++ ) { if ( ( c . charAt ( i ) - '0' ) == 1 ) b += '0' ; else b += '1' ; } System . out . print ( Integer . parseInt ( b , 2 ) ) ; } public static void main ( String [ ] args ) { int a = 4 ; maxValue ( a ) ; } }