<s>[INST] 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?
 [/INST] 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}.
$$
</s>