# 89. 格雷编码

[https://leetcode-cn.com/problems/gray-code/](https://leetcode-cn.com/problems/gray-code/)

## 解法一：

思路很简单，用异或G(i) = i^ (i/2)

```python
class Solution:
    def grayCode(self, n: int) -> List[int]:
        res = []
        for i in range(2**n):
            res.append(i ^ i//2)
        return res
```
