Objective
The Gray code orders the n-bit numbers so that two consecutive ones differ in a single bit. Value i of the sequence is obtained with i ^ (i >> 1).
Instructions
- The input is an integer
n(between 1 and 6). - Show the
2**nGray codes ofnbits, one per line and in binary with leading zeros, starting ati = 0.
2
00
01
11
10
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise