<s>[INST] Why doesn't this calculation work? I want to find some closed form for $\gcd(x^3+1,3x^2 + 3x  + 1)$ but get $7$ which is not always true.
 [/INST] First
$$
3(x^3+1)-(3x^2+3x+1)(x-1)=2x+4
$$
and
$$
2(3x^2+3x+1)-3(2x+4)(x-1)=14
$$
Thus, we have
$$
(3x^2-6x+5)(3x^2+3x+1)-9(x-1)(x^3+1)=14
$$
and thus, $(x^3+1,3x^2+3x+1)\mid14$. Since $3x^2+3x+1=6\binom{x+1}{2}+1$, it is always odd. Thus, we can improve the statement to
$$
(x^3+1,3x^2+3x+1)\mid7
$$
If we look mod $7$, we see that the gcd is $7$ when $x\equiv5\pmod7$ and $1$ otherwise.
</s>