title: If given two hexadecimal numbers find if they can be consecutive in gray code
body: <p>What is "consecutive in gray code" supposed to mean? I mean 10 and 11 are consecutive in decimal system but what is "consecutive in gray code" meaning? I only know gray code is a binary numeral system where two successive values differ in only one bit.</p>
  
  <p>Here is a solution online but I cannot understand this</p>
  
  <pre><code>private static int graycode(byte term1, byte term2) {  
    byte x = (byte)(term1^term2);  // why use XOR?
    int count = 0;  
    while(x!=0)  
    {  
      x = (byte)(x &amp;(x-1));  // why use bitwise operator?
      count++;               // what is count?
    }  
    return count == 1;  
  }  
  </code></pre>
  
  <p>I try to understand spending a hour but I still do not have a clue.</p>