2

The following code show the gray code for upto last $input

function getGrayCode($n) {
    return $n ^ ($n >> 1);
 };

$input = 62;
$max = (1 << $input);
for( $i= $max- $input ; $i<$max; $i++) {
    printf("%s\n", decbin(getGrayCode($i)));   
}

The above code is working for $input value 62 but its not working for the rang 62 < $input <= 65. Can anyone solve it?

0 Answers0