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

3 lines
104 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
graycode[n_]:=BitXor[n,BitShiftRight[n]]
graydecode[n_]:=Fold[BitXor,0,FixedPointList[BitShiftRight,n]]