Number of values of $n\in \mathbb{Z}$ such that $n^2+n+2$ is a perfect square

61 Views Asked by At

My approach:

Case $1$: $n$ is positive:

Let $x\in\mathbb{Z}$, so $$n^2+n+2=x^2$$ $$\implies n+2=x^2-n^2=(x+n)(x-n)$$

$$\therefore x-n=\frac{n+2}{x+n}$$ $\because x\in \mathbb{Z}$ and $n\in \mathbb{Z}$, so $$n+2\ge x+n$$$$\implies x\le 2$$ $$\therefore x^2 \le 4$$

Case $2$: $n$ is negative: Let $n=-k$ where $k \in \mathbb{N}$

$$\therefore 2-k=x^2-k^2=(x+k)(x-k)$$ $$\therefore x+k=\frac{2-k}{x-k}$$

$\because x\in \mathbb{Z}$ and $n\in \mathbb{Z}$, so $$2-k\ge x-k$$$$\implies x\le 2$$ $$\therefore x^2 \le 4$$

In both cases, $x^2\le 4$, so the only possible values of $n^2+n+2$ as a perfect square are ${1,4}$.

If $x^2=1$ $$n^2+n=-1$$ which has no real solutions.

If $x^2=4$ $$n^2+n=2$$ $$n=1,-2$$

So the answer is $2$

Is my approach correct? If yes, can someone show me shorter or more elegant methods to solve this?