ta có \(\frac{n^2-n+1}{n+1}=\frac{\left(n^2+n\right)-\left(2n+2\right)+3}{n+1}=\frac{n\left(n+1\right)-2\left(n+1\right)+3}{n+1}=\frac{\left(n+1\right)\left(n-2\right)+3}{n+1}=n-2+\frac{3}{n+1}\):
để \(n^2-n+1⋮n+1\) thì \(3⋮n+1\)
=> n+1=3 hoặc n+1=-3
=> n=2 hoặc n=-4
vậy với n=2 hoặc n=-4 thì \(n^2-n+1⋮n+1\)