Problems > N-th Gray Code > Editorial

N-th Gray Code — Solution & Editorial

Back to the Problem

The closed form is G(N) = N ⊕ (N >> 1) — prove by induction on the reflection construction.

Complexity: O(1)