If $n$ is a positive integer, what is the smallest value that the sum of the digits in the decimal representation of $3 n^{2}+n+1$ can take?

#
Solution

If $n=8$, we have that $3 n^{2}+n+1=201$ and the sum of its digits is 3. We will now verify that the sum of the digits of $3 n^{2}+n+1$ cannot be 1 or 2 and conclude that the smallest possible value is 3. Since $n(n+1)$ is the product of two consecutive numbers, it is even, and thus $3 n^{2}+n+1=2 n^{2}+n(n+1)+1$ is an odd number. For the sum of the digits to be 1, we must have $3 n^{2}+n+1=10^{k}$. This is impossible, as $3 n^{2}+n+1>1$ and $10^{k}$ is even for $k>1$. For the sum of the digits to be 2, we must have $3 n^{2}+n+1=10^{i}+10^{j}$, with $i>j$ or $3 n^{2}+n+1=2 \cdot 10^{k}$. The second option is invalid, as $2 \cdot 10^{k}$ is even. In the first option, since $10^{i}+10^{j}$ needs to be odd, we must have $j=0$, that is,

\[
\begin{aligned}
3 n^{2}+n+1 & =10^{i}+1 \\
n(3 n+1) & =10^{i} \\
n(3 n+1) & =2^{i} \cdot 5^{i}
\end{aligned}
\]

If a prime number $p$ divides $n$, then it divides $3 n$ and, consequently, cannot divide its successor $3 n+1$. Thus, $n$ and $3 n+1$ do not have common prime factors. Since $n4^{i}>3 \cdot 2^{i}+1=3 n+1
\]

When $i=1$, there is no solution, as $5 \neq 3 \cdot 2+1$. This concludes our analysis and shows that the minimum sum of the digits is 3.