[Math] Find all positive integers $n$ such that $n^2+n+43$ becomes a perfect square

diophantine equationselementary-number-theory

Find all positive integers $n$ such that $n^2+n+43$ becomes a perfect square.
Since $n^2+n+43$ is odd,if it's a perfect square it can be written as: $8k+1$,then:
$$n^2+n+43=8k+1\Rightarrow\ n^2+n+42=8k\ \Rightarrow\ n(n+1)\equiv6\pmod8$$
So $n$ becomes $2,5,…$ but $5$ doesn't work!!

Best Answer

If $n^2+n+43$ is a square, so it is $$4n^2+4n+172 = (2n+1)^2 + 171. $$ If $171=a^2-(2n+1)^2$, then $171=(a-2n-1)(a+2n+1).$ Since $$ 171 = 3^2\cdot 19 $$ the only ways for writing $171$ as a product of two positive integers with the same parity are: $$ 1\cdot 171,\qquad 3\cdot 57,\qquad 9\cdot 19. $$ For instance, if $a-2n-1=9$ and $a+2n+1=19$, then $(19-9)=4n+2$ and $n=2$.

In the same way we get that the whole set of integer solutions is given by: $$ n\in\color{red}{\{-43,-14,-3,2,13,42\}}.$$