Gray to Binary and Binary to Gray conversion | Javascript program for above approach ; Driver code
function greyConverter ( n ) { return n ^ ( n >> 1 ) ; } let n = 3 ; document . write ( greyConverter ( n ) + " " ) ; n = 9 ; document . write ( greyConverter ( n ) ) ;