Decimal Equivalent of Gray Code and its Inverse | Java Program to convert given decimal number of gray code into its inverse in decimal form ; Function to convert given decimal number of gray code into its inverse in decimal form ; Taking xor until n becomes zero ; Driver code
import java . io . * ; class GFG { static int inversegrayCode ( int n ) { int inv = 0 ; for ( ; n != 0 ; n = n >> 1 ) inv ^= n ; return inv ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . println ( inversegrayCode ( n ) ) ; } }