The first n numbers without consecutive equal binary digits The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits.

The sequence is probably easiest to explain by just showing the relationships between the binary and decimal representations of the numbers:

0       -&gt;  0
1       -&gt;  1
10      -&gt;  2
101     -&gt;  5
1010    -&gt;  10
10101   -&gt;  21
101010  -&gt;  42


Challenge:

Take an input integer n, and return the first n numbers in the sequence. You may choose to have the sequence 0-indexed or 1-indexed.

Test cases:

n = 1   &lt;- 1-indexed
0

n = 18
0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682, 1365, 2730, 5461, 10922, 21845, 43690, 87381


Explanations are encouraged, as always.

This is OEIS A000975.
Python 2, 36 bytes



lambda n:[2**i*2/3for i in range(n)]


Try it online! Explanation: The binary representation of \$\frac{2}3\$ is 0.101010101... so it simply remains to multiply it by an appropriate power of 2 and take the integer portion.