How to find the sum of the the first n elements in the series 1,2,4,5,7,8.... as a function of n? I see I can split it up into two arithmetic series (1,4,7... and 2,5,8...) and add the two sums, but what is the compact notation for the sum of these two series as a function of n?
 A: If you consider
$$a_k=1+3k\qquad b_k=2+3k$$ then
$$\sum_{k=0}^n a_k=\sum_{k=0}^n (1+3k)=\sum_{k=0}^n 1+3\sum_{k=0}^n k=n+1+3 \frac{1}{2} n (n+1)=\frac{1}{2} (n+1) (3 n+2)$$
$$\sum_{k=0}^n b_k=\sum_{k=0}^n (2+3k)=2\sum_{k=0}^n 1+3\sum_{k=0}^n k=2(n+1)+3 \frac{1}{2} n (n+1)=\frac{1}{2} (n+1) (3 n+4)$$
Just continue.
A: Let us first find the formula for even $n$. In this case, $m = n/2$ is a whole number, and moreover the sum of the first $n$ elements of your sequence is the sum of the first $m$ elements of the two arithmetic progressions, that is,
$$
m + 3\frac{m(m-1)}{2} + 2m + 3\frac{m(m-1)}{2} = 3 (m + m(m-1)) = \frac{3n^2}{4}.
$$
If $n$ is odd, then $n-1$ is even and we know that the sum of the first $n-1$ entries is $\frac{3(n-1)^2}{4}$. Moreover, the last entry in the sequence was the $((n-1)/2 + 1)$-st entry of the first arithmetic progression, that is $1,4,7,10, \ldots$. But the value of that entry is $3 ((n-1)/2 + 1) - 2 = 3(n-1)/2 + 1$, so using the formula for the even case, the sum of the first $n$ entries equals
$$
\frac{3(n-1)^2}{4} + 3(n-1)/2 + 1 = \frac{3}{4} (n^2 - 2n + 2n + 1 - 2 + 4/3) = \frac{3n^2}{4} + \frac{1}{4}.
$$
A: Your sequence $1,2,4,5,7,8,\dots$ satisfies the second order nonhomogeneous linear recurrence
$$a_n=a_{n-2}+3$$
with initial values
$$a_1=1,\ a_2=2.$$
The solution is
$$a_n=\frac{6n-3-(-1)^n}4.$$
The sum of the first $n$ terms is
$$\sum_{k=1}^n a_k=\frac34n^2+\frac{1-(-1)^n}8=\boxed{\frac34n^2+\frac{1-\cos n\pi}8}.$$
