Answer: 23n+1
Solution 1: Note that a2n−1=1 for all n by repeatedly applying a2i+1=ai. Now let bn= a0+a1+a2+⋯+a2n−1. Applying the given recursion to every term of bn except a0 gives
bn=====a0+a1+a2+a3+⋯+a2n−1a0+a2+a4+⋯+a2n−2+a1+a3+⋯+a2n−1a0+(a0+a1)+(a1+a2)+(a2+a3)+⋯+(a2n−1−2+a2n−1−1)+a0+a1+a2+⋯+a2n−1−13a0+3a1+3a2+⋯+3a2n−1−2+3a2n−1−1−a2n−1−13bn−1−1.
Now we easily obtain bn=23n+1 by induction.
Solution 2: Define a binary string to be good if it is the null string or of the form 101010…10. Let cn be the number of good subsequences of n when written in binary form. We see c0=1 and c2n+1=cn because the trailing 1 in 2n+1 cannot be part of a good subsequence. Furthermore, c2n+2−cn+1 equals the number of good subsequences of 2n+2 that use the trailing 0 in 2n+2. We will show that this number is exactly cn.
Let s be a good subsequence of 2n+2 that contains the trailing 0 . If s uses the last 1 , remove both the last 1 and the trailing 0 from s; the result s′ will be a good subsequence of n. If s does not use the last 1 , consider the sequence s′ where the trailing 0 in 2n+2 is replaced by the last 0 in n (which is at the same position as the last 1 in 2n+2.) The map s↦s′ can be seen to be a bijection, and thus c2n+2=cn+cn+1.
Now it is clear that an=cn for all n. Consider choosing each binary string between 0 and 2n−1 with equal probability. The probability that a given subsequence of length 2k is good is 22k1. There are (2kn) subsequences of length 2k, so by linearity of expectation, the total expected number of good subsequences is
k=0∑⌊n/2⌋22k(2kn)=2(1+1/2)n+(1−1/2)n=2n+13n+1.
This is equal to the average of a0,…,a2n−1, therefore the sum a0+⋯+a2n−1 is 23n+1.