\(x^3-x^2-x-2=x^3-2x^2+x^2-2x+x-2\) \(-2\)
\(=\) \(x^2\left(x-2\right)+x\left(x-2\right)+\left(x-2\right)\)
\(=\left(x^2+x+1\right)\left(x-2\right)\)
\(x^3-6x^2-x+30=x^3+2x^2-8x^2-16x+15x+30\)
\(=x^2\left(x+2\right)-8x\left(x+2\right)+15\left(x+2\right)\)
\(=\) \(\left(x^2-8x+15\right)\left(x+2\right)\)
\(=\left(x^2-5x-3x+15\right)\left(x+2\right)\)
\(=\left(x-5\right)\left(x-3\right)\left(x+2\right)\)