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.
 A: 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.
A: With your procedure you found that the GCD between the two polynomials $x^3+1$ and $3x^2+3x+1$ in $\mathbb{Q}[x]$ is $7$, or equivalently $1$, because the GCD of polynomials is defined up to constants (every scalar value $c$ divides any polynomial $p(x)\in\mathbb{Q}[x]$). 
Thus there is not contradiction in your statement.
A: I prove the gcd $\,d =7\,$ if $\, x = 5\!+\!7n,\,$ else $\,d=1.\,$ First $\,x^3\!+\!1 = (x\!+\!1)h(x),\ h(x) = x^2\!-\!x\!+\!1.\,$  Let $\,g(x) = 3x^2\!+3x+1.\,$ Then  $\,\color{#c00}{(x\!+\!1,g(x))} = (x\!+\!1,g(-1)) = (x+1,1)= \color{#c00}1.\,$ Therefore $\,d = ((\color{#c00}{x\!+\!1})h ,\color{#c00}g) = (h,g) = (h,\, g\ {\rm mod}\ h) = (\color{#0a0}{h,2}(3x\!-\!1))\,$ by $\,x^2\equiv x\!-\!1\,$ mod $\,h.\>$ But $\,2\mid h\!-\!1=x(x-1)
,\, $ so $\ \color{#0a0}{(h,2) = 1},\,$ so $\ d = (h,\ 3x\!-\!1).\,$ Reducing $\,h\,$ mod $\,3x\!-\!1$ we obtain  $\,{\rm mod}\ d\!:\ 0\equiv 9h(x)\equiv 9h(1/3)\equiv 7,\, $ so $\,d\mid 7.\,$ So $\,d\ne 1\iff (h,3x\!-\!1)=7\,$ which is true iff $\,x\equiv -2\equiv 5\pmod 7,\,$  i.e. the common root of $\,3(x\!+\!2)\,$ and $\,h \equiv (x\!+\!2)(x\!-\!3)\,\pmod 7.$
