<p>Given a positive integer <code>n</code>, return the number of the integers in the range <code>[0, n]</code> whose binary representations <strong>do not</strong> contain consecutive ones.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 5
<strong>Output:</strong> 5
<strong>Explanation:</strong>
Here are the non-negative integers &lt;= 5 with their corresponding binary representations:
0 : 0
1 : 1
2 : 10
3 : 11
4 : 100
5 : 101
Among them, only integer 3 disobeys the rule (two consecutive ones) and the other 5 satisfy the rule. 
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 2
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 3
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>9</sup></code></li>
</ul>

class Solution:
    def findIntegers(self, n: int) -> int:
        f = [1,2]
        for i in range(2, 30):
            f.append(f[-1] + f[-2])
        
        ans = last_seen = 0
        for i in range(n.bit_length()-1,-1,-1):
            if (1 << i) & n:
                ans += f[i]
                if last_seen :
                    return ans
                last_seen = 1
            else:
                last_seen = 0
        return ans + 1
'''
000
001
010
011

100
101
110
111

10 XXX
0 XXXX

f(n) = f(n-1) + f(n-2)

f(0) = 1
f(1) = 2
f(2) = 3
f(3) = 5
f(4) = 8
f(5) = 13

2^n - 1 -> n -> Recurrance to solve

20
0 - 31: 5 bits

21 - 31

21 = 16 + 4 + 1

V
10101

0
1
10
100
101
1001
1010
10000
10001
10010
10100
10101


'''
        
16200