Find all integers $n$ for which $n^2+n+1$ is a perfect square.
By hit and trial we get $n=-1,0$ but could someone suggest any genuine approach as how to approach this problem?
Find all integers $n$ for which $n^2+n+1$ is a perfect square.
By hit and trial we get $n=-1,0$ but could someone suggest any genuine approach as how to approach this problem?
Usually, $n^2+n+1$ is between the consecutive squares $n^2$ and $n^2+2n+1=(n+1)^2$
Hint: If $n^2+n+1=x^2$ then $4n^2+4n+4=4x^2$ so $(2n+1)^2+3=4x^2$. When do two perfect squares differ by $3$?
Note that $n^2 + n + 1 = (n+1)^2 - n$. Now if $n > 0$, then $(n+1)^2 > (n+1)^2 - n > n^2$, so the quantity $(n+1)^2 - n$ is stuck between two consecutive squares and thus cannot be a square.
Similarly, if $n < -1$, then $(n+1)^2 < (n+1)^2 - n < n^2$ yields a contradiction. So you've found all the solutions.
Assuming that $n^2+n+1$ is a square, $4n^2+4n+4 = (2n+1)^2+3$ is a square, too, so there are two squares having difference $3$. The only squares with such a property are $1$ and $4$: draw your conclusions.
HINT:
$$(2n+1)^2+3=(2m)^2\iff3=(2n+1-2m)(2n+1-2m)$$
What are the factors of $3$?
We have: $n^2 + n + 1 = m^2 \implies n^2 + n + (1-m^2) = 0 \implies \triangle = 1^2 - 4(1)(1-m^2) = k^2 \implies 1-4(1-m^2) = k^2 \implies 4m^2 - k^2 = 3 \implies (2m+k)(2m-k) = 3\implies 2m+k = 3, 2m-k = 1$ or $2m+k = -1, 2m-k = -3$. Either case gives $n^2 + n = 0 \implies n = -1, 0$.
As other solutions stated , one of your values can be obtained as like ,
$ n^2+n+1=k^2 \equiv 1 (mod 3) \implies n(n+1)\equiv 0 (mod 3)$
So $3|n$ or $3| (n+1)$ , put $n=3k$ , $f(k)=9k^2+3k+1=(3k+1)^2 - 3k$ which implies $n=k=0$ .
Secondly if $3|(n+1)$ put $n=3k-1$ & we get $ f(k)=9k^2-3k+1=(3k-1)^2+3k$ which forces $k=0$ & thus $n=3.0-1=-1$
We have $n^2<n^2+n+1<(n+1)^2$ and $n^2+n+1$ is perfect square for $n=0,-1$ .