\(\frac{x^2}{x+1}=\frac{x\left(x+1\right)-x}{x+1}=\frac{x\left(x+1\right)}{x+1}-\frac{x}{x+1}=x-\frac{x}{x+1}\in Z\)
\(\Rightarrow x⋮x+1\)
\(\Rightarrow\frac{x}{x+1}=\frac{x+1-1}{x+1}=\frac{x+1}{x+1}-\frac{1}{x+1}=1-\frac{1}{x+1}\in Z\)
\(\Rightarrow1⋮x+1\)\(\Rightarrow x+1\inƯ\left(1\right)=\left\{1;-1\right\}\)
\(\Rightarrow x\in\left\{0;-2\right\}\)
\(x^2⋮x+1\)
\(\Rightarrow x^2-1+1⋮x+1\)
\(\Rightarrow\left(x-1\right).\left(x+1\right)+1⋮x+1\)
Do \(\left(x-1\right).\left(x+1\right)⋮x+1\) nên \(1⋮x+1\)
\(\Rightarrow x+1\in\left\{1;-1\right\}\)
\(\Rightarrow x\in\left\{0;-2\right\}\)
Vậy \(x\in\left\{0;-2\right\}\)