\(x^3-x^2-21x+45\)
\(=\left(x^3-3x^2\right)+\left(2x^2-6x\right)+\left(-15x+45\right)\)
\(=x^2\left(x-3\right)+2x\left(x-3\right)-15\left(x-3\right)\)
\(=\left(x^2+2x-15\right)\left(x-3\right)\)
\(=\left[\left(x^2-3x\right)+\left(5x-15\right)\right]\left(x-3\right)\)
\(=\left[x\left(x-3\right)+5\left(x-3\right)\right]\left(x-3\right)\)
\(=\left(x+5\right)\left(x-3\right)^2\)