7. For exactly four integer values of $n$ between 1 and 10, inclusive, the expression $n^{9}+3^{n+1} n^{6}+3^{3 n}$ represents a prime number. What is the sum of these four values of $n$?
(A) 12
(B) 16
(C) 18
(D) 22
(E) 25
7. The answer is $\mathbf{( B )}$. If $n=3 k$ with $k$ an integer, it is clear that $n^{9}+3^{n+1} n^{6}+3^{3 n}$ is divisible by $3$ and therefore for $n=3,6,9$ the expression does not represent a prime number.

Suppose instead that $n=3 k+1$ with $k$ an integer. Then

$$
n^{9}+3^{n+1} n^{6}+3^{3 n}=(3 k+1)^{9}+3^{3 k+2}(3 k+1)^{6}+3^{9 k+3}
$$

This expression is of the form $a^{3}+3 a^{2} b+b^{3}$, with $a=(3 k+1)^{3}$ and $b=3^{3 k+1}$. We can complete the cube, obtaining

$$
a^{3}+3 a^{2} b+b^{3}=a^{3}+3 a^{2} b+3 a b^{2}+b^{3}-3 b^{2} a=(a+b)^{3}-3 b^{2} a
$$

and from the definition of $a$ and $b$ it follows that $3 b^{2} a=\left(3^{2 k+1}(3 k+1)\right)^{3}$. Recalling that in general $x^{3}-y^{3}=(x-y)\left(x^{2}+y x+y^{2}\right)$, we obtain that

$$
(a+b)^{3}-3 b^{2} a=\left(a+b-3^{2 k+1}(3 k+1)\right)\left((a+b)^{2}+3^{2 k+1}(3 k+1)(a+b)+3^{4 k+2}(3 k+1)^{2}\right) .
$$

It is easily verified that for $k=1,2,3$ both factors are strictly greater than 1, and thus for $n=4,7,10$ the expression $n^{9}+3^{n+1} n^{6}+3^{3 n}$ does not represent a prime number. By elimination, with $n=1,2,5,8$ four prime numbers are obtained. The answer is therefore $1+2+5+8=$ 16 .