\(x^3-5x^2+3x+9\)
\(=x^3-3x^2-2x^2+6x-3x+9\)
\(=x^2\left(x-3\right)-2x\left(x-3\right)-3\left(x-3\right)\)
\(=\left(x-3\right)\left(x^2-2x-3\right)\)
\(=\left(x-3\right)\left(x^2+x-3x-3\right)\)
\(=\left(x-3\right)\left[x\left(x+1\right)-3\left(x+1\right)\right]\)
\(=\left(x-3\right)^2\left(x+1\right)\)