```
public int rangeBitwiseAnd(int m, int n) {
int result = 0, num, i;
for (i=31;i>=0;i--) {
num = 1 << i;
if ((num & n) > 0) {
if ((num & m) > 0)
result += num;
else
break;
}
}
return result;
}
}
```