Finding a polynomial by divisibility 
Let $f(x)$ be a polynomial with integer coefficients. If $f(x)$ is divisible by $x^2+1$ and $f(x)+1$ by $x^3+x^2+1$, what is $f(x)$?

My guess is that the only answer is $f(x)=-x^4-x^3-x-1$, but how can I prove it?
 A: In fact, there are infinitely many solutions. If $f(x)=-x^4-x^3-x-1$ and $g(x)$ is any polynomial, then
$$f(x)+g(x)(x^2+1)(x^3+x^2+1)$$
is a solution.
A: This is a straightforward application of CRT = Chinese Remainder Theorem.
By hypothesis $\ (x^2\!+1)g = f = -1 + (x^3\!+x^2\!+1)h\ $ for some polynomials $\,g,h,\,$ so
${\rm mod}\ x^2\!+\!1\!:\ x^2\equiv -1\,\Rightarrow\,1\equiv (x^3\!+x^2\!+1)h\equiv -xh\,\Rightarrow\, h \equiv -1/x\equiv x^2/x\equiv \color{#c00}x$
Therefore $\ h = \color{#c00}x + (x^2\!+1)h',\ $ for some polynomial $\,h'$
$\!  \begin{align}{\rm hence}\ \  f\, =&\, -1 + (x^3\!+x^2\!+1)(\color{#c00}x+(x^2\!+1)h')\\  =&\ \ x^4\!+x^3\!+x-1 + (x^3\!+x^2\!+1)(x^2\!+1) h'\end{align}$
A: One way you could express this idea is through functions $g,h$ where $$f(x) = g(x)(x^2+1) \\ f(x)+1 = h(x)(x^3+x^2+1)$$ This means that $$g(x)(x^2+1)+1 =h(x)(x^3+x^2+1)$$ or that $$h(x) = \frac{g(x)(x^2+1)+1}{x^3+x^2+1}$$ So you could begin by choosing any polynomial $g$ you want so long as it forces $h$ to be a polynomial. Then $f$ will be a polynomial.
