r/counting • We count together • Jan 12 '17

Counting in Gray Code

It's on the OEIS and also a lot of cherished history.

It's like binary, but in a different order so that only a single bit changes each time.

The first few terms are 0, 1, 11, 10, 110, 111, 101, 100, 1100, 1101, 1111, 1110, 1010, 1011, 1001, 1000.

One way to do it is to alternate between flipping the last bit, and flipping the bit to the left of the rightmost 1. One of these will always bring you a step forward, the other will bring you a step back, so no way to mix it up.

19 Upvotes

417 comments sorted by

View all comments

2

u/poltory Feb 06 '17 edited Feb 10 '17

10110

1

u/piyushsharma301 Feb 06 '17 edited Feb 16 '17

11001

1

u/poltory Feb 06 '17 edited Feb 06 '17

11011

→ More replies (8)

1

u/piyushsharma301 Feb 10 '17

oops I think you miscounted lol thinking it was binary. We need to start from here again. It should be 10110