Ta có: \(-n^2+7⋮n-2\)
\(\Leftrightarrow-\left(n^2-7\right)⋮n-2\)
\(\Leftrightarrow n^2-7⋮n-2\)
\(\Leftrightarrow n^2-2n+2n-4-3⋮n-2\)
\(\Leftrightarrow n\left(n-2\right)+2\left(n-2\right)-3⋮n-2\)
\(\Leftrightarrow\left(n-2\right)\left(n+2\right)-3⋮n-2\)
mà \(\left(n-2\right)\left(n+2\right)⋮n-2\)
nên \(-3⋮n-2\)
\(\Leftrightarrow n-2\inƯ\left(-3\right)\)
\(\Leftrightarrow n-2\in\left\{1;-1;3;-3\right\}\)
hay \(n\in\left\{3;1;5;-1\right\}\)
Vậy: \(n\in\left\{3;1;5;-1\right\}\)