GCD of $X^3+1$ and $X^2+1$ in a field K let K be a field of characteristic $p$.
I try to find $\gcd(X^3+1,X^2+1)$
We have, $\gcd(X^3+1,X^2+1)=\gcd(X^3+1,X-1)=\gcd(X+1,X-1)=\gcd(X-1,2)$ 
I didn't know how to go from there, but the solution in my book says:
if $p \neq 2$, then $ \gcd(X^3+1,X^2+1)=1$ else $\gcd(X^3+1,X^2+1)=X+1$
Could you please help me understand this solution? Why it is $X+1$ and not $X-1$ ? how does $p$ play in this ?
I know that the $p$ is the minimal integer that verifies: $\forall x\in K : px=0_K$
Many thanks.

Since $X^3+1=X(X^2+1)-(X-1)$, we have
$$
\gcd(X^3+1,X^2+1)=\gcd(X^2+1,X-1)
$$
Since $X^2+1=X(X-1)+(X+1)$, we have
$$
\gcd(X^2+1,X-1)=\gcd(X-1,X+1)
$$
Since $X-1=(X+1)-2$, we have
$$
\gcd(X-1,X+1)=\gcd(X+1,2)
$$
If $p=2$, then $2=0$, so the greatest common divisor is $X+1$ (the last nonzero remainder). If $p\ne2$, the element $2$ is invertible, so we can conclude that the greatest common divisor is $1$.
