# 201. Bitwise AND of Numbers Range

[Link](https://leetcode.com/problems/bitwise-and-of-numbers-range/)

**Solution**

先舉例 比方說 n=4, m=6\
**1**00\
**1**01\
**1**10\
答案是 100\
問題可以理解成找出bit表示裡面common的prefix。然後後面用0補上

```
  public int rangeBitwiseAnd(int m, int n) {
        if(m == 0){
            return 0;
        }
        int i = 0; // right side 0 count
        while(m != n){
            m >>= 1;
            n >>= 1;
            i++;
        }
        return m<<i;
    }
```
