Determine the greatest common divisor of polynomials $x^2+1$ and $x^3+1$ in $\Bbb Q[X]$. Exercise: Determine a gcd of the polynomials $x^2+1$ and $x^3+1$ in $\Bbb Q[X]$.. Write the gcd as a combination of the given polynomials.
Is it correct that I keep using long division until the result is $0$, and then the previous result would be a gcd?
x^2+1 / x^3 + 1 \ x
        x^3 + x
        ________-
        1 - x

1 - x / x^2 + 1 \ -x-1
        x^2 - x 
        ________-
        x + 1
        x - 1
        ________-
        2

2 / 1 - x \ -1/2x + 1/2 
      - x 
    ______-
    1
    1
    ______-
    0

Conclusion: A gcd is $2$?
I'm not sure what's meant with "Write the gcd as a combination of the given polynomials.", so it would be great if someone could point me in the right direction.
 A: The Euclidean algorithm steps are 
\begin{align*}
x^3+1&=x (x^2+1) + (-x+1)\\
x^2+1&=-x (-x+1)+ (x+1)\\
-x+1&=-(x+1)+2
\end{align*}
So the GCD is $1$.
We can go back up
\begin{align*}
2 &= (-x+1) +(x+1)\\
&= (-x+1) + (x^2+1)+x (-x+1)\\
&= (-x+1) (x+1)+(x^2+1)\\
&= (x^3+1 - x(x^2+1))(x+1)+(x^2+1)\\
&= (x+1) (x^3+1) + (-x^2-x+1) (x^2+1)
\end{align*}
and so $1 = \frac{1}{2} [(x+1) (x^3+1) + (-x^2-x+1) (x^2+1)]$
A: Notice that $x^2+1$ is irreducible over $\mathbb{Q}$. Let $d = \gcd(x^2+1, x^3+1)$. Then $d \mid  x^2+1$ so $d$ is a nonzero constant, or $d$ is an associate of $x^2+1$.
However, $x^2+1 \not\mid x^3+1$ so $d$ must be constant. We can choose $d = 1$ since $\gcd$ is usually supposed to be monic.
Finally, notice that
$$1=\left[\frac{1}{2}(x+1) \right](x^3+1) + \left[\frac{1}{2}(-x^2-x+1)\right] (x^2+1)$$
A: $$  \left(   x^{3}  + 1 \right)  $$ 
$$  \left(   x^{2}  + 1 \right)  $$ 
$$  \left(   x^{3}  + 1 \right)  =  \left(   x^{2}  + 1 \right)  \cdot \color{magenta}{  \left(   x  \right) } +  \left(   -  x  + 1 \right)  $$ 
 $$  \left(   x^{2}  + 1 \right)  =  \left(   -  x  + 1 \right)  \cdot \color{magenta}{  \left(   -  x  - 1 \right) } +  \left( 2  \right)  $$ 
 $$  \left(   -  x  + 1 \right)  =  \left( 2  \right)  \cdot \color{magenta}{  \left(   \frac{  -  x  + 1 }{ 2 }  \right) } +  \left( 0 \right)  $$ 
 $$ \frac{ 0}{1} $$ 
 $$ \frac{ 1}{0} $$ 
 $$ \color{magenta}{  \left(   x  \right) }  \Longrightarrow  \Longrightarrow  \frac{  \left(   x  \right) }{ \left( 1  \right) } $$ 
 $$ \color{magenta}{  \left(   -  x  - 1 \right) }  \Longrightarrow  \Longrightarrow  \frac{  \left(   -  x^{2}  -  x  + 1 \right) }{ \left(   -  x  - 1 \right) } $$ 
 $$ \color{magenta}{  \left(   \frac{  -  x  + 1 }{ 2 }  \right) }  \Longrightarrow  \Longrightarrow  \frac{  \left(   \frac{  x^{3}  + 1 }{ 2 }  \right) }{ \left(   \frac{  x^{2}  + 1 }{ 2 }  \right) } $$ 
 $$  \left(   x^{3}  + 1 \right)  \left(   \frac{  -  x  - 1 }{ 2 }  \right)  -  \left(   x^{2}  + 1 \right)  \left(   \frac{  -  x^{2}  -  x  + 1 }{ 2 }  \right)  =  \left( -1  \right)  $$ 
..................................
