<s>[INST] Algebraic Closed Form for $\sum_{n=1}^{k}\left( n- 3 \lfloor \frac{n-1}{3} \rfloor\right)$ Let's look at the following sequence:
$a_n=\left\{1,2,3,1,2,3,1,2,3,1,2,3,...\right\}$
I'm trying to calculate:

$$\sum_{n=1}^{k} a_n$$

Attempts: 
I have a Closed Form for this sequence. 

$$a_n=n- 3 \bigg\lfloor \frac{n-1}{3}  \bigg\rfloor$$

The problem is, I'm looking for a closed form for this summation:

$$\sum_{n=1}^{k}\left( n- 3 \bigg\lfloor \frac{n-1}{3}  \bigg\rfloor\right)$$

Is it possible?
 [/INST] If you consider$$b_k=\sum_{n=1}^{k}\left( n- 3 \bigg\lfloor \frac{n-1}{3}  \bigg\rfloor\right)$$ you could see, after some simple manipulationd that it corresponds to the recurrence relation
$$b_k=b_{k-1}+b_{k-3}-b_{k-4}\qquad \text{with}\qquad b_1=1, b_2=3, b_3=6, b_4=7$$ Using the conventional method  you should end with
$$b_k=2k-\frac{2}{3} \left(1-\cos \left(\frac{2 \pi  k}{3}\right)\right)$$
Edit
If you enjoy the floor function, using a CAS, I got for $b_k$ the small monster
$$\frac{1}{2} \left(k^2+k-3 \left\lfloor \frac{k}{3}\right\rfloor ^2-3 \left\lfloor
   \frac{k-2}{3}\right\rfloor  \left(\left\lfloor \frac{k-2}{3}\right\rfloor
   +1\right)-3 \left\lfloor \frac{k-1}{3}\right\rfloor  \left(\left\lfloor
   \frac{k-1}{3}\right\rfloor +1\right)+3 \left\lfloor \frac{k}{3}\right\rfloor
   \right)$$
Which one do you prefer ?
</s>