Problem 934: (2014 AIME II, 7)
Let $f(x)=(x^2+3x+2)^{\cos(\pi x)}$. Find the sum of all positive integers $n$ for which \[ \left |\sum_{k=1}^n\log_{10}f(k)\right|=1. \]
- $\log_{10}f(k)=(-1)^k\bigl(\log(k+1)+\log(k+2)\bigr)$, so the sum telescopes to $-\log2+(-1)^n\log(n+2)$.
- For even $n$, $\log\frac{n+2}2=\pm1$ gives $n=18$. For odd $n$, $\log(2(n+2))=1$ gives $n=3$.
- $18+3=21$. The answer is $\boxed{021}$.
Let $f(x)=(x^2+3x+2)^{\cos(\pi x)}$. Find the sum of all positive integers $n$ for which \[ \left |\sum_{k=1}^n\log_{10}f(k)\right|=2. \]