The Gray Code is a sequence of binary numbers of bitwidth
n where successive numbers differ only in one bit (see example output).
000 001 011 010 110 111 101 100
- This question seems to have a dupe but it's not, for that question is not a code-golf, and it demands different output. It will help to check out it's answers, though.
- You may assume a variable
nwhich contains the input.