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.

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)$$
