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

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!!

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\}}.$$

• The OP wants $n$ positive.
– lhf
May 13, 2016 at 16:24
• Then just $2,13,42$. May 13, 2016 at 16:29

$n^2+n+43=m^2$ iff $4n^2+4n+172=4m^2$ iff $(2n+1)^2+171=(2m)^2$.

Let $u=2n+1$ and $v=2m$. Then $171 = v^2-u^2 =(v+u)(v-u)$.

Since $171 = 3 \cdot 3 \cdot 19$, we can try all possibilities for $v+u$ and $v-u$ and then find $n$ and $m$.

All odd perfect squares are of the form 8k+1 but all numbers of the form 8k+1 are not perfect squares in this case 73 generated by 5 is not a perfect square but is of the form 8k+1.

Trying to solve: $n^2+n+43=m^2$, multiply by $4$ and complete the square, and you get:

$$(2n+1)^2+4\cdot 43-1 = (2m)^2.$$

Subtract and you are trying to solve $(2m)^2-(2n+1)^2=171$.

The difference of two squares means you need:

$$(2(m-n)-1)(2(m+n)+1)=171=9\cdot 19$$

So you need to factor $171$ as two odd numbers whose sum is a multiple of $4$.

There will only be finitely many solutions.

Alternatively, you know that if $n>42$ then $n^2<n^2+n+43<n^2+2n+1=(n+1)^2$. So you only have to check finitely many values $n$.

• For the last part of your answer ,I think in case $n>42$ there is no value of $n$ producing a square,since $n^2+n+43$ lies between two consecutive squares. May 13, 2016 at 19:44

Other answers have given a quick way to find all positive $n$'s for which $n^2+n+43$ is a square. Here, mainly for fun, is a slow way.

If $n^2+n+43=k^2$, with $k\ge0$, then $n+43=(k+n)(k-n)$. In particular $k+n$ divides $n+43$, so it can't be greater than $n+43$. Thus $k\le43$. This leaves a finite number of cases to check.