\(A=\left(x^4-x^3\right)-\left(x^2-1\right)=x^3\left(x-1\right)-\left(x-1\right)\left(x+1\right)\)
\(=\left(x-1\right)\left(x^3-x-1\right)\)
\(B=x\left(x+1\right)^2-5\left(x+1\right)^2+x\left(x-5\right)\)
\(=\left(x-5\right)\left(x+1\right)^2+x\left(x-5\right)\)
\(=\left(x-5\right)\left[\left(x+1\right)^2+x\right]=\left(x-5\right)\left(x^2+3x+1\right)\)