\(u=x+2\Rightarrow x=u-2\Rightarrow du=dx\)
\(\Rightarrow\int\left(x-1\right)^2\left(x+2\right)^{21}dx=\int\left(u-3\right)^2.u^{21}du\)
\(=\int\left(u^2-6u+9\right)u^{21}du=\int\left(u^{23}-6u^{22}+9u^{21}\right)du=\dfrac{1}{23}u^{24}-\dfrac{6}{23}u^{23}+\dfrac{9}{22}u^{22}=...\)