Ta có :
\(f\left(x\right)=x^3+ax^2+2x+b\)
\(f\left(x\right)=x\left(x^2+x+1\right)+\left(a-1\right)\left(x^2+x+1\right)+\left(2-a\right)x+b-a+1\)\(f\left(x\right)=\left(x+a-1\right)\left(x^2+x+1\right)+\left(2-a\right)x+b-a+1\)
⇒ Để \(f\left(x\right)\) chia hết cho \(g\left(x\right)\)thì
\(\left(2-a\right)x+b-a+1=0\)
⇒\(\left\{{}\begin{matrix}2-a=0\\b-a+1=0\end{matrix}\right.\)
⇒\(\left\{{}\begin{matrix}a=2\\b=1\end{matrix}\right.\)