If $f(x)=x^3+2x^2+x+2$, find the remainder when $f(x)$ is divided by $(x+2)^2$.
I tried two methods.
First, using polynomial long division, I got the answer $5x+10$.
I factored the polynomial as $f(x)=(x^2+1)(x+2)$.
So, $\dfrac{f(x)}{(x+2)^2}=\dfrac{x^2+1}{x+2}$
But this one gives $5$ as the remainder, with long division.
Why is the second method incorrect or what did I miss?