Determine all integers $n$ for which the polynomial $P(x)=3 x^{3}-n x-n-2$ can be written as the product of two non-constant polynomials with integer coefficients.
Suppose $P(x)$ can be written as $P(x)=A(x) B(x)$ with $A$ and $B$ being non-constant polynomials with integer coefficients. Since $A$ and $B$ are not constant, they each have a degree of at least 1. The sum of the two degrees is equal to the degree of $P$, which is 3. This means that the two degrees must be 1 and 2. We can thus write, without loss of generality, $A(x)=a x^{2}+b x+c$ and $B(x)=d x+e$ with $a, b, c, d$ and $e$ being integers. The product of the leading coefficients $a$ and $d$ is equal to the leading coefficient of $P$, which is 3. Since we could also multiply both $A$ and $B$ by -1, we may assume that $a$ and $d$ are both positive and thus, in some order, equal to 1 and 3.

First, assume that $d=1$. Substitute $x=-1$. We have

$$
P(-1)=3 \cdot(-1)^{3}+n-n-2=-5,
$$

so

$$
-5=P(-1)=A(-1) B(-1)=A(-1) \cdot(-1+e).
$$

We see that $-1+e$ is a divisor of -5, so it is equal to $-5, -1, 1$ or 5. This gives four possible values for $e$, namely $-4, 0, 2$ or 6. Furthermore, $x=-e$ is a root of $B$ and thus also of $P$.

If $e=-4$, then

$$
0=P(4)=3 \cdot 4^{3}-4 n-n-2=190-5 n
$$

so $n=38$. We can indeed factorize $P(x)$ as follows:

$$
3 x^{3}-38 x-40=\left(3 x^{2}+12 x+10\right)(x-4)
$$

If $e=0$, then

$$
0=P(0)=-n-2
$$

so $n=-2$. We can indeed factorize $P(x)$ as follows:

$$
3 x^{3}+2 x=\left(3 x^{2}+2\right) x
$$

If $e=2$, then

$$
0=P(-2)=3 \cdot(-2)^{3}+2 n-n-2=-26+n
$$

so $n=26$. We can indeed factorize $P(x)$ as follows:

$$
3 x^{3}-26 x-28=\left(3 x^{2}-6 x-14\right)(x+2)
$$

If $e=6$, then

$$
0=P(-6)=3 \cdot(-6)^{3}+6 n-n-2=-650+5 n
$$

so $n=130$. We can indeed factorize $P(x)$ as follows:

$$
3 x^{3}-130 x-132=\left(3 x^{2}-18 x-22\right)(x+6)
$$

Now assume that $d=3$. We have

$$
-5=P(-1)=A(-1) B(-1)=A(-1) \cdot(-3+e)
$$

We see that $-3+e$ is a divisor of -5, so it is equal to $-5, -1, 1$ or 5. This gives four possible values for $e$, namely $-2, 2, 4$ or 8. Furthermore, $x=\frac{-e}{3}$ is a root of $B$ and thus also of $P$. We see that $e$ is never divisible by 3. We have

$$
0=P\left(\frac{-e}{3}\right)=3 \cdot\left(\frac{-e}{3}\right)^{3}+\frac{e}{3} n-n-2=-\frac{e^{3}}{9}+\frac{e-3}{3} n-2,
$$

so $\frac{e-3}{3} n=\frac{e^{3}}{9}+2$, thus $(e-3) n=\frac{e^{3}}{3}+6$. But this leads to a contradiction, because the left side is an integer and the right side is not, since 3 is not a divisor of $e$.

We conclude that the solutions are: $n=38, n=-2, n=26$ and $n=130$.