I'm trying to find all $n \in \mathbb{N}$ such that
$(n+2) \mid (n^2+5)$
as the title says, I've tried numbers up to $20$ and found that $1, 7$ are solutions and I suspect that those are the only $2$ solutions, however I have no idea how to show that.
I've done nothing but basic transformations:
$(n+2) \mid (n^2+5)$
$\iff n^2+5 = k(n+2)$
$\iff n^2+5 \mod(n+2) = 0$
$\iff (n^2 \mod(n+2) + 5 \mod(n+2)) \mod(n+2) = 0$
Now I suspect the next step is to find all possible solutions for
$n^2 \mod(n+2)$, which I have no idea how to do.
$$n+2\left|n^2+5\right. \implies k(n+2) = n^2+5 \implies k = \frac{n^2+5}{n+2}$$ Use that $$k = \frac{n^2+5}{n+2}=n-2+\frac{9}{n+2}$$