RosettaCodeData/Task/Gray-code/Mathematica/gray-code.math

3 lines
104 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
graycode[n_]:=BitXor[n,BitShiftRight[n]]
graydecode[n_]:=Fold[BitXor,0,FixedPointList[BitShiftRight,n]]