Decimal Equivalent of Gray Code and its Inverse | C # 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
using System ; class GFG { static int inversegrayCode ( int n ) { int inv = 0 ; for ( ; n != 0 ; n = n >> 1 ) inv ^= n ; return inv ; } public static void Main ( ) { int n = 15 ; Console . Write ( inversegrayCode ( n ) ) ; } }