Evaluating $\sum_{k=0}^n(-1)^{\frac{k(k+1)}2}k$ I asked this question a few days ago, where I noticed $$\left\lfloor\frac{n}4\right\rfloor+\left\lfloor\frac{n+1}4\right\rfloor-\left\lfloor\frac{n+2}4\right\rfloor-\left\lfloor\frac{n+3}4\right\rfloor=\cos\left(\frac{n\pi}{2}\right)-1,\quad n\in\mathbb N$$
We can also write $\cos\left(\frac{n\pi}{2}\right)-1=\sum_{k=1}^n(-1)^{\frac{k(k+1)}2}$, and so I decided to try and evaluate $$\sum_{k=1}^n(-1)^{\frac{k(k+1)}2}k$$
to perhaps arrive at a another equivalence between trigonometric and floor functions(I do realise that we are only using trivial values of the cosine, but nevertheless find it rather intriguing).

I have arrived at a trigonometric relation as follows:
Since $\sum_{k=1}^nka_k=n(a_1+a_2+\dots+ a_n)-\sum_{k=1}^n(a_1+a_2+\dots+a_{k-1})$, we have (for $a_k=(-1)^{\frac{k(k+1)}2}$ )
$$\begin{align}\sum_{k=1}^nk(-1)^{\frac{k(k+1)}2}&=n\left(\cos\left(\frac{n\pi}{2}\right)-1\right)-\sum_{k=1}^n\left(\cos\left(\frac{k\pi}{2}\right)-1\right)\\
&=n\cos\frac{n\pi}{2}-\frac{\sin(\frac{n\pi}4)}{\sin\frac\pi4}\cdot\cos\frac{(n-1)\pi}4\\
&=n\cos\frac{n\pi}{2}-\frac{1}{\sqrt2}\cdot\sin\frac{(2n-1)\pi}4-\frac12
\end{align}$$
While not as concise as I had hoped, it is still a simple trigonometric equation. My problem however, lies in somehow generating a floor function evaluation for the series. Could somebody please help? Thanks in advance!
 A: We can write the series as $$\sum_{k=1}^n(-1)^{\frac{k(k+1)} 2}k=\sum_{4j\le n}4j+\sum_{4j-1\le n}(4j-1)-\sum_{4j-2\le n}(4j-2)-\sum_{4j-3\le n}(4j-3)$$
Since $$\sum_{4j\le n}4j=\left(4+8+\dots+4\left\lfloor\frac n4\right\rfloor\right)=\frac12\left\lfloor\frac n4\right\rfloor\left(2\cdot4+\left(\left\lfloor\frac n4\right\rfloor-1\right)\cdot4\right)$$
$$\implies\sum_{4j\le n}4j=2\left\lfloor\frac n4\right\rfloor^2+2\left\lfloor\frac n4\right\rfloor$$
We can use this result to evaluate the remaining terms as :
$$\sum_{4j-1\le n}(4j-1)=\sum_{4j\le n+1}4j-\sum_{4j\le n+1}1=2\left\lfloor\frac {n+1}4\right\rfloor^2+2\left\lfloor\frac {n+1}4\right\rfloor-\left\lfloor\frac {n+1}4\right\rfloor$$
$$\implies\sum_{4j-1\le n}(4j-1)=2\left\lfloor\frac {n+1}4\right\rfloor^2+\left\lfloor\frac {n+1}4\right\rfloor$$
Similarly,
$$\sum_{4j-2\le n}(4j-2)=2\left\lfloor\frac {n+2}4\right\rfloor^2,\sum_{4j-3\le n}(4j-3)=2\left\lfloor\frac {n+3}4\right\rfloor^2-\left\lfloor\frac {n+3}4\right\rfloor$$
Thus,
$$\sum_{k=1}^n(-1)^{\frac{k(k+1)} 2}k=2\left(\left\lfloor\frac {n}4\right\rfloor^2+\left\lfloor\frac {n+1}4\right\rfloor^2-\left\lfloor\frac {n+2}4\right\rfloor^2-\left\lfloor\frac {n+3}4\right\rfloor^2\right)\\+2\left\lfloor\frac {n}4\right\rfloor+\left\lfloor\frac {n+1}4\right\rfloor+\left\lfloor\frac {n+3}4\right\rfloor$$
$$\bbox[5px,border:2px solid #C0A000]{\begin{align} n\cos\frac{n\pi}{2}-\frac{1}{\sqrt2}\cdot\sin\frac{(2n-1)\pi}4-\frac12=&2\left(\left\lfloor\frac {n}4\right\rfloor^2 +\left\lfloor\frac {n+1}4\right\rfloor^2-\left\lfloor\frac {n+2}4\right\rfloor^2-\left\lfloor\frac {n+3}4\right\rfloor^2\right)\\&+2\left\lfloor\frac {n}4\right\rfloor+\left\lfloor\frac {n+1}4\right\rfloor+\left\lfloor\frac {n+3}4\right\rfloor \end{align}}$$
