Solution (source code)

= Solution

By the <polynomial remainder theorem>, the first <polynomial remainder> is $f(1)=23-2p$. Equating it to $9$ gives \b[$p=7$].

For the separate <polynomial long division>, successively cancel the leading powers of the dividend. Subtracting $x^2(x-1)$ leaves $2x^2+2x+1$; subtracting $2x(x-1)$ leaves $4x+1$; subtracting $4(x-1)$ leaves $5$. Thus
$$
x^3+x^2+2x+1=(x-1)(x^2+2x+4)+5,
\qquad\boxed{\text{quotient }x^2+2x+4,\quad\text{remainder }5.}
$$
The <polynomial remainder> also equals the dividend evaluated at $x=1$.