Ta có :
\(x^3+ax^2+2x+b\)
\(=x^3+x^2+x+\left(a-1\right)x^2+x+b\)
\(=x\left(x^2+x+1\right)+\left(a-1\right)x^2+ax-x+a-1+2x-ax-a+b+1\)
\(=x\left(x^2+x+1\right)+\left(a-1\right)x^2+x\left(a-1\right)+a-1+2x-ax-a+b+1\)
\(=x\left(x^2+x+1\right)+\left(a-1\right)\left(x^2+x+1\right)+2x-ax-a+b+1\)
\(=\left(a-1+x\right)\left(x^2+x+1\right)+\left(2-a\right)x+b-a+1\)
\(\Rightarrow\) \(x^3+ax^2+2x+b:\left(x^2+x+1\right)\) dư \(\left(2-a\right)x+b-a+1\)
Để chia hết thì \(\left(2-a\right)x+b-a+1=0\)
\(\Leftrightarrow\left\{{}\begin{matrix}2-a=0\\b-a+1=0\end{matrix}\right.\Leftrightarrow\left\{{}\begin{matrix}a=2\\b=a-1\end{matrix}\right.\)
\(\Leftrightarrow a=2;b=1\)
Vậy ..