limit. Count the integers from 0 to limit inclusive whose binary representation never has two ones next to each other.limit=6 → 5
In binary, 0…6 are 0, 1, 10, 11, 100, 101, 110. 3 (11) and 6 (110) have two ones in a row, which leaves 5 numbers.
limit=8 → 6
The valid ones are 0, 1, 2, 4, 5 and 8, six in total.
limit=1 → 2
limit ≤ 10⁹limit=6
5
Run checks the first 3 tests in your browser. Submit checks all 27 tests on the server, hidden ones included.