Let \[f\left( x \right)\text{ }=\text{ }{{x}^{3}}~+\text{ }3{{x}^{2}}~+\text{ }ax\text{ }+\text{ }b\]
As, \[\left( x\text{ }\text{ }2 \right)\] is a factor of f(x), so \[f\left( 2 \right)\text{ }=\text{ }0\]
\[{{\left( 2 \right)}^{3}}~+\text{ }3{{\left( 2 \right)}^{2}}~+\text{ }a\left( 2 \right)\text{ }+\text{ }b\text{ }=\text{ }0\]
\[8\text{ }+\text{ }12\text{ }+\text{ }2a\text{ }+\text{ }b\text{ }=\text{ }0\]
\[2a+b+20=0\] … (i)
And as, \[\left( x\text{ }+\text{ }1 \right)\] is a factor of f(x), so \[f\left( -1 \right)\text{ }=\text{ }0\]
\[{{\left( -1 \right)}^{3}}~+\text{ }3{{\left( -1 \right)}^{2}}~+\text{ }a\left( -1 \right)\text{ }+\text{ }b\text{ }=\text{ }0\]
\[-1\text{ }+\text{ }3\text{ }\text{ }a\text{ }+\text{ }b\text{ }=\text{ }0\]
\[-a\text{ }+\text{ }b\text{ }+\text{ }2\text{ }=\text{ }0\] … (ii)
Subtracting (ii) from (i), we have
\[\begin{array}{*{35}{l}}
3a\text{ }+\text{ }18\text{ }=\text{ }0 \\
a\text{ }=\text{ }-6 \\
\end{array}\]
On substituting the value of a in (ii), we have
\[b\text{ }=\text{ }a\text{ }\text{ }2\text{ }=\text{ }-6\text{ }\text{ }2\text{ }=\text{ }-8\]
Thus, f(x) = \[{{x}^{3}}~+\text{ }3{{x}^{2}}~\text{ }6x\text{ }\text{ }8\]
Now, for \[x\text{ }=\text{ }-1\]
\[f\left( -1 \right)\text{ }=\text{ }{{\left( -1 \right)}^{3}}~+\text{ }3{{\left( -1 \right)}^{2}}~\text{ }6\left( -1 \right)\text{ }\text{ }8\text{ }=\text{ }-1\text{ }+\text{ }3\text{ }+\text{ }6\text{ }\text{ }8\text{ }=\text{ }0\]
Therefore, \[\left( x\text{ }+\text{ }1 \right)\] is a factor of f(x).
Now, performing long division we have
Hence,
\[~f\left( x \right)\text{ }=\text{ }\left( x\text{ }+\text{ }1 \right)\text{ }({{x}^{2}}~+\text{ }2x\text{ }\text{ }8)\]
\[=\text{ }\left( x\text{ }+\text{ }1 \right)\text{ }({{x}^{2}}~+\text{ }4x\text{ }\text{ }2x\text{ }\text{ }8)\]
\[=\text{ }\left( x\text{ }+\text{ }1 \right)\text{ }\left[ x\left( x\text{ }+\text{ }4 \right)\text{ }\text{ }2\left( x\text{ }+\text{ }4 \right) \right]\]
\[=\text{ }\left( x\text{ }+\text{ }1 \right)\text{ }\left( x\text{ }+\text{ }4 \right)\text{ }\left( x\text{ }\text{ }2 \right)\]