pub fn gray(i: usize) -> usize
The binary reflected Gray code $g(i) = i \oplus \lfloor i/2 \rfloor$.
use comnum_math::gray; assert_eq!((0..8).map(gray).collect::<Vec<_>>(), [0, 1, 3, 2, 6, 7, 5, 4]);