Question:For each positive integer $n$, we define $f(n)$ to be the number of unique triangles (triangles that only differ by a rotation or a reflection are considered the same), with integer side lengths, that have positive area and perimeter $n$. For example, $f(0)=f(1)=f(2)=0$ and $f(3)=1$. Compute $\sum_{n=1}^{100} (-1)^nf(n)$.
Logic:Let $a \geq b \geq c$ be the three sides of a triangle - these three values determine exactly $1$ distinct triangle by SSS congruence. We have the restriction $b+c>a$ and all the other triangle inequalities are implied by $a \geq b \geq c$. Let $z = b+c$. Then the minimum value of $z$ is $\lfloor \frac{n}{2} \rfloor + 1$ because that is the lowest integer always strictly greater than $\frac{n}{2}$. The maximum is $n-1$ because then $a >0$ has a minimum of $1$. $z$ can take any value in between.
Now, for each $z$, since $b$ is greater than or equal to $c$, it's clear $b$'s minimum value is $\lceil \frac{z}{2} \rceil$, which is the smallest integer greater than or equal to $\frac{z}{2}$. However, $b$'s maximum value is $a$ itself, since $a \geq b$ and this doesn't go past the $z$-value, since $z>a$. This means the number of values $b$ can take is $a-\lceil \frac{z}{2} \rceil + 1 = n+z-\lceil \frac{z}{2} \rceil + 1$.
Therefore, since the number of values that $z$ and $b$ can take total (implying the values of $a$ and $c$ respectively) is the number of noncongrouent (nondegeneracy has already been adressed) triangles with integer side lengths and perimeter $n$ by SSS congruence, this number seemingly is $\sum_{z=\lfloor \frac{n}{2} \rfloor + 1}^{n-1} n+1 - z - \lceil \frac{z}{2} \rceil$; however, it actually isn't. We forgot to adress the cases for $n+1 - z - \lceil \frac{z}{2} \rceil$ being negative - sometimes it is, but that just means that there are zero values of $b$ for that specific value of $z$ - it doesn't subtract from the values we've already counted. The values of $z$ (for a set value of $n$) is $n+1 - z - \lceil \frac{z}{2} \rceil$ that are negative have to satisfy $z + \lceil \frac{z}{2} \rceil > n+1$. For odd $z$, $\lceil \frac{z}{2} \rceil = \frac{z+1}{2}$, which implies $\frac{3z+1}{2}> n+1$, implying $z>\frac{2n+1}{3}$. For even $z$, $\lceil \frac{z}{2} \rceil = \frac{z}{2}$, so $\frac{3z}{2} > n+1$, implying $z < \frac{2n+2}{3}$. These restrictions on $z$ imply all negative cases of $n+1 - z - \lceil \frac{z}{2} \rceil$.
Looking at $n$ mod $6$, we see the following cases: $n \equiv 0$ mod $6$ implies the maximum value of $z$ to be $\frac{2n}{3}$, since $n$ is even and $2n\equiv 0$ mod $3$. $n \equiv 1$ mod $6$ implies the maximum value of $z$ to be $\frac{2n+1}{3}$, since $n$ is odd and $2n+1\equiv 0$ mod $3$. $n \equiv 2$ mod $6$ implies the maximum value of $z$ to be $\frac{2n+2}{3}$, since $n$ is even and $2n+2\equiv 0$ mod $3$. $n \equiv 3$ mod $6$ implies the maximum value of $z$ to be $\frac{2n}{3}$, since $n$ is odd and $2n\equiv 0$ mod $3$. $n \equiv 4$ mod $6$ implies the maximum value of $z$ to be $\frac{2n+1}{3}$, since $n$ is even and $2n+1\equiv 0$ mod $3$. $n \equiv 5$ mod $6$ implies the maximum value of $z$ to be $\frac{2n-1}{3}$, since $n$ is odd and and $2n-1\equiv 0$ mod $3$. Now, let $p(n) = \left\{ \begin{array}{ll} 0 & \quad n \equiv 0\ \text{mod}\ 6 \\ 1 & \quad n \equiv 1\ \text{mod}\ 6 \\ 2 & \quad n \equiv 2\ \text{mod}\ 6 \\ 0 & \quad n \equiv 3\ \text{mod}\ 6 \\ 1 & \quad n \equiv 4\ \text{mod}\ 6 \\ -1 & \quad n \equiv 5\ \text{mod}\ 6 \\ \end{array} \right.$ Then, the maximum value of $z$ that is nonnegative is $\frac{2n+p(n)}{3}$, so our function $f(n)$ is equal to $$\sum_{z=\lfloor \frac{n}{2} \rfloor + 1}^{\frac{2n+p(n)}{3}} n+1 - z - \lceil \frac{z}{2} \rceil.$$ Now, to find $f(2n)-f(2n-1)$, note that $p(2n)-1=p(2n-1)$ for any $n$. Then $\frac{2(2n)+p(2n)}{3}$ $=$ $\frac{4n+p(2n)}{3}$ and $\frac{2(2n-1)+p(2n-1)}{3}$ $=$ $\frac{4n-2+p(2n)-1}{3}$ $=$ $\frac{4n+p(2n)}{3}-1$.
Also, note that $\lfloor \frac{2n}{2} \rfloor + 1$ $=$ $n+1$ and $\lfloor \frac{2n-1}{2} \rfloor + 1$ = $n$.
Then, $f(2n)-f(2n-1)=$ $$\sum_{z=\lfloor \frac{2n}{2} \rfloor + 1}^{\frac{2(2n)+p(2n)}{3}} 2n+1 - z - \lceil \frac{z}{2} \rceil- \sum_{z=\lfloor \frac{2n-1}{2} \rfloor + 1}^{\frac{2(2n-1)+p(2n-1)}{3}} 2n-1+1-z - \lceil \frac{z}{2} \rceil$$$$=\sum_{z=n+1}^{\frac{4n+p(2n)}{3}} 2n+1 - z - \lceil \frac{z}{2} \rceil- \sum_{z=n}^{\frac{4n+p(n)}{3}-1} 2n-z - \lceil \frac{z}{2} \rceil$$$$=\sum_{z=n+1}^{\frac{4n+p(2n)}{3}}1+ \sum_{z=n+1}^{\frac{4n+p(2n)}{3}}2n-z-\lceil \frac{z}{2} \rceil - \sum_{z=n}^{\frac{4n+p(n)}{3}-1} 2n-z - \lceil \frac{z}{2} \rceil$$$$=\frac{4n+p(2n)}{3}-n-1+1+2n-\frac{4n+p(2n)}{3}-\lceil \frac{\frac{4n+p(2n)}{3}}{2} \rceil-2n + n+\lceil \frac{n}{2} \rceil$$$$=\lceil \frac{n}{2} \rceil-\lceil \frac{4n+p(2n)}{6} \rceil.$$ Now, we need to find $\sum_{n=1}^{100}-1^nf(n)$ $=$ $\sum_{n=1}^{50}f(2n)-f(2n-1)$ $=$ $\sum_{n=1}^{50}\lceil \frac{n}{2} \rceil-\lceil \frac{4n+p(2n)}{6} \rceil$ $=$ $\sum_{n=1}^{50}\lceil \frac{n}{2} \rceil- \sum_{n=1}^{50}\lceil \frac{4n+p(2n)}{6} \rceil$. Looking at $\lceil \frac{n}{2} \rceil$, we see that any $\lceil \frac{2n-1}{2} \rceil = \lceil \frac{2n}{2} \rceil = n$. Then, $\sum_{n=1}^{50}\lceil \frac{n}{2} \rceil$ becomes $2\sum_{n=1}^{25}n = 650$. Looking at $\lceil \frac{4n+p(2n)}{6} \rceil$, we see that $p(2n)$ always follows a strict sequence: $2,1,0,2,1,0...$, so the difference between any consecutive values of $p(2n)$ from the difference between consecutive terms (starting between $n=1$ and $n=2$) follows the sequence $-1,-1,2,-1,-1,2$; adding this to $4n$, we see that the difference between any consecutive values of $4n+p(2n)$ from the difference between consecutive terms (starting between $n=1$ and $n=2$) follows the sequence $3,3,6,3,3,6...$. Dividing our entire function by $6$, we see our differences (starting from $n=1$ to $n=2$) follow the sequence $\frac12, \frac12, 1, \frac12, \frac12, 1...$. However, $\frac{4(1)+p(2(1))}{6}=1$, so our sequence is $1,\frac32,2,3,\frac72,4,...$. Note that every $n^{th}$ term for $n \equiv 2$ mod $3$ is a fraction; this is because we add $\frac12$ to a whole number. Applying the ceiling function on our entire sequence makes it $1,2,2,3,4,4...$ - this sequence describes the values of $\lceil \frac{4n+p(2n)}{6} \rceil$, since we applied the ceiling function on $\frac{4n+p(2n)}{6}$. We want the sum of the first $50$ terms, so this is just the sum of $1,2,2,3,4...32,33,34$. Grouping every $3$ terms together, we see a constant difference (since our difference sequence resets every three terms, and our ceiling function raises the second of those three terms by $\frac12$). This is a difference of $6$ - we see $1+2+2=5$, $3+4+4=11$, and so on, until $31+32+32=95$ (we'll add on the $33$ and $34$ later). This is just an arithmetic series with $16$ terms, first term $5$, and difference $6$ resulting in a sum $8(10+15*6)=800$. Adding on the $33$ and $34$, we get $\sum_{n=1}^{50}\lceil \frac{4n+p(2n)}{6} \rceil = 867$. Now, our final sum is $\sum_{n=1}^{100}-1^nf(n)$ $=$ $\sum_{n=1}^{50}f(2n)-f(2n-1)$ $=$ $\sum_{n=1}^{50}\lceil \frac{n}{2} \rceil-\lceil \frac{4n+p(2n)}{6} \rceil$ $=$ $\sum_{n=1}^{50}\lceil \frac{n}{2} \rceil- \sum_{n=1}^{50}\lceil \frac{4n+p(2n)}{6} \rceil$ $=$ $650-867$ $=$ $\boxed{-217}$.
Help is greatly appreciated!