Total number of triangles in a triangular grid I once tried to find how to quickly find the total number of squares in a bigger, $n\times n$ grid. I’m sure you’ve seen one of these puzzles, and the bigger the grid, the more embedded squares there are and the more chance you have of miscounting. So I finally came up with the answer
$$ \sum^n_{k=1}k^2$$ which can be simplified to $$\frac{n(n+1)(2n+1)}{6}$$ Then later on, I wanted to try the same with a triangular (equilateral) grid, where the size $n$ corresponds to the side of the triangle.

So I eventually found a formula that has two summation terms, one inside the other, with some even/odd evaluator ($n$ is the size of a side): $$T(n)=\sum^n_{k=1}\bigg(\frac{3-(-1)^{n-k}}{2}\sum^k_{j=1}j\bigg)$$
The fraction in between the two sums is the even/odd evaluator, and determines if $n-k$ is even or odd. Now this looks long and tedious, and for large grid sizes, only a computer could do it without a chance of mistaking. Now for the important part, my question is this: Is there a way to simplify the formula in a similar way than the square grid one? Yes, I did try Wolfram Alpha, and it just gave me back the summation form of the formula.

First, lets start with what we know. We know that
$$ A_m:= \sum_{k=1}^mk=\frac{m(m+1)}{2} \; \; \; \; \; \; \; \; \; \; \; \; \; \; B_m:=\sum_{k=1}^mk^2=\frac{m(m+1)(2m+1)}{6}$$
Now lets try to work out $$ C_n :=\sum_{k=1}^n(-1)^kk \; \; \; \; \; \; \; \; \; \; \; \; \; \; D_n:=\sum_{k=1}^n(-1)^kk^2$$
assuming tha $n$ is even. Observe that $$C_n=-A_n+4A_{n/2}=-\frac{n(n+1)}{2}+4\frac{\frac n2 (\frac n2+1)}{2}=\frac n2$$
$$D_n=-B_n+8B_{n/2}=-\frac{n(n+1)(2n+1)}{6}+8\frac{\frac n2(\frac n2+1)(n+1)}{6}=\frac{n(n+1)}{2}$$
For $n$ being odd, we simply break the sum into two parts and use the above, i.e.
$$C_n=\sum_{k=1}^n(-1)^kk=\sum_{k=1}^{n-1}(-1)^kk-n=\frac {n-1}{2} -n=-\frac{n+1}{2}$$
Similarly,
$$D_n=\frac{n(n-1)}{2}-n^2=-\frac{n(n+1)}{2}$$
Now, I assume that your formula for $T(n)$ is correct, so using that, we get
\begin{align}
\ T(n) & = \sum_{k=1}^n \biggl(\frac{3-(-1)^{n-k}}{2}\sum_{j=1}^kj\biggr) \\
\ & = \sum_{k=1}^n \biggl(\frac{3-(-1)^{n-k}}{2} \frac{k(k+1)}{2} \biggr) \\
\ & = \sum_{k=1}^n \biggl(\frac 34 k^2 + \frac 34 k - \frac{(-1)^{n-k}}{4}k^2-\frac{(-1)^{n-k}}{4}k \biggr) \\
\end{align}
Now supposing that $n$ is even
\begin{align}
\ & = \frac 34 \frac{n(n+1)(2n+1)}{6}+ \frac 34 \frac{n(n+1)}{2}-\frac{(-1)^n}{4}\frac{n(n+1)}{2} -\frac{(-1)^n}{4} \frac n2 \\
\ & = \frac{n(n+1)(n+2)}{4} - \frac{(-1)^nn(n+2)}{8} \\
\ & = \frac{n(n+2)(2n+2-(-1)^n)}{8} \\
\ & = \frac{n(n+2)(2n+1)}{8}
\end{align}
Similarly, for $n$ odd, we plug in the odd expression for the sums
\begin{align}
\ & = \frac 34 \frac{n(n+1)(2n+1)}{6}+ \frac 34 \frac{n(n+1)}{2}+\frac{(-1)^n}{4}\frac{n(n+1)}{2} +\frac{(-1)^n}{4} \frac {n+1}{2} \\
\ & = \frac{n(n+1)(n+2)}{4} + \frac{(-1)^n(n+1)^2}{8} \\
\ & = \frac{(n+1)(2n^2+3n-1)}{8}
\end{align}
