```
class Solution {
func rangeBitwiseAnd(_ m: Int, _ n: Int) -> Int {
if m == 0 {
return 0
}
var m = m
var n = n
var factor = 1
while m != n {
m >>= 1
n >>= 1
factor <<= 1
}
return m * factor
}
}
```