Build a tree to consider all possible number.

Let 1.and 0 for each bit be tree node

compress to 4 possible result for each bit:

- all bit before cur is less than num and no continues 1 and cur bit is at one.
- all bit before cur is less than num and no continues 1 and cur bit is at zero.
- cur and prev bit is equal to num.
- larger than num or has contiunes '1'.

then run through the tree.

```
public class Solution {
public int findIntegers(int num) {
//one:all bit before cur is less than num and no continues 1 and cur bit is at one;
//zero:all bit before cur is less than num and no continues 1 and cur bit is at zero;
int one=0,zero=0,temp;
boolean isNum=true;
for(int i=31;i>=0;i--){
temp=zero;
zero+=one;
one=temp;
if(isNum&&((num>>i)&1)==1){
zero+=1;
}
if(((num>>i)&1)==1&&((num>>i+1)&1)==1){
isNum=false;
}
}
return one+zero+(isNum?1:0);
}
}
```