Prove that if n is a perfect square, then n+2 is not a perfect square

I'm working on proving the following statement:

If n is a perfect square, then n+2 is not a perfect square.

I also need to state this in first order logic with arithmetic, but have no idea what that looks like.

The only start I have so far in terms of the proof is:

$n$ = $a^2$

$n+2$ = $b^2$

But I don't know how to proceed from here? I've seen solutions to this already but do not understand how they actually prove anything.

• $b^2 \ge (a+1)^2 = n + 2a+1 \ge n+3$. Oct 23, 2013 at 19:09

Let's assume w.o.l.g that $a, b >= 0$

$b^2 = n+2$

$a^2 = n$

So $b^2 - a^2 = 2$, which means $(b-a)(b+a) = 2$. So $(b+a)$ is a divisor of 2 (either 1 or 2, since $b+a>0$).

Now only a few cases remain

• $a = 0, b=1$
• $a = 1, b=0$
• $a = 0, b=2$
• $a = 1, b=1$
• $a = 2, b=0$

No case has $b^2 - a^2 = 2$

• Perhaps a nicer way to prove this is by noting that $a$ and $b$ must be consecutive (otherwise $a$ and $b$ differ by $2$ or more, which means their squares differ by $4$ or more. And if they are consecutive, the difference of their squares is odd. The proof by @njguliyev in the comment is also neat. Aug 6, 2020 at 21:27

First, for $n = 1$:

$n = 1$: $n^2 = 1$, $n^2 + 2 = 3$, 3 is not a perfect square

For $n \ge 2$:

There are no perfect squares between $n^2$ and $(n + 1)^2$, exclusive. For $n \ge 2$, $n^2 < n^2 + 2 < (n + 1)^2$, so $n + 2$ is not a perfect square.

For the "logic" part of your question, assume that variables range over nonnegative integers, or the integers. Then we can write $$\forall x\left(\exists t (x=t\times t)\longrightarrow \lnot\exists s(x+2=s\times s) \right).$$ If you are working in first-order Peano arithmetic, replace $x+2$ by $S(S(x))$.

$\forall n\in\mathbb{N}, n^2\equiv0 \text{ or }1 (\mod 4)$.

However, $n^2+2\equiv2 \text{ or }3 (\mod 4)$.

$a^2-b^2\not\equiv2\pmod4$

As $a-b=a+b-2b$

so, $a+b,a-b$ are of same parity

If one is even, so will be other $\implies a^2-b^2=(a+b)(a-b)\equiv0\pmod4$

If one is odd, so will be other $\implies a^2-b^2=(a+b)(a-b)$ will be odd $\not\equiv2\pmod4$

• What does mod 4 mean? I'm not familiar with that. Oct 23, 2013 at 19:06
• @Bob, It means $\%4$. See here( mathworld.wolfram.com/Congruence.html) Oct 23, 2013 at 19:10
• The notation denotes "modular equivalence" or "modular congruence". If the two sides were congruent, then this notation is a fancy way of saying that for any a and b, the expression on the left, when modulo divided by 4, would always equal 2. Because the two sides are not equivalent modulo 4, this is not the case; no two values A and B, when squared, subtracted and divided by 4, would have a remainder of 2. Oct 23, 2013 at 19:10
• How can I use the fact that for the proof? Oct 23, 2013 at 19:12
• @Bob, you need to show $a^2-b^2\ne2$ , I prove $a^2-b^2\ne4C+2$ for all integer $C$ Oct 23, 2013 at 19:15

Bob - The first thing to do is to make sure you believe the result is true. What can you say about the gaps between consecutive squares: 1, 4, 9, 16, ... ? Are any of these gaps 2? If not, how can you demonstrate that this is always the case? (Hint: consider $a^2$ and $(a+1)^2$.) Once you're sure the result can be proved, then you can worry about how to write it.

• The fact that there are no gaps of 2 makes a lot of sense that n+2 is not a perfect square. But how do I prove it? Oct 23, 2013 at 19:15
• The difference between $(a+1)^2$ and $a^2$ is $2a+1$, which has its smallest value (3) when $a=1$. So, consecutive squares differ by at least 3, i.e., $n$ and $n+2$ cannot both be squares, because they differ by 2. Oct 23, 2013 at 19:31

If $n=a^2$ then the next square is $(a+1)^2$

The claim is true for $a=0$ (i.e. $0+2$ is not a perfect square), then for $a \ge 1$:

$(a+1)^2-a^2=2a+1 \gt 2$

and so $n+2$ will be less than the next square.

• How did you come up with the statement for a is greater than or equal to 1? Oct 23, 2013 at 19:24
• $(a+1)^2 = a^2+2a+1$ Oct 23, 2013 at 19:47

Let's take it from where you left off, but phrase it this way:

Let $$n = a^{2}$$, where $$a$$ is an integer.

Now, let's assume for the sake of contradiction that $$n + 2 = b^{2}$$, for some integer $$b$$.

Then, taking the difference $$b^{2} - a^{2}$$, we get

$$(b + a)(b - a) = b^{2} - a^{2} = (n + 2) - n = 2,$$

which is impossible (for if either $$b - a$$ or $$b + a$$ is equal to $$1$$, the other cannot equal $$2$$.)

Let us assume $$n+2$$ is a perfect square: then, since $$n$$ is a perfect square, $$n=a^2$$ (where $$a$$ is a positive integer).
Since according to our assumption, $$n+2$$ is a perfect square, $$n+2=b^2$$ (where $$b$$ is a positive integer) Then, we have , $$a^2 +2=b^2$$ Since the sum of a perfect square (here, $$a^2$$) and an imperfect square (here, $$2$$) is always an imperfect square, we know that the left hand side of the equation is an imperfect square and the right hand side of the equation is a perfect square (according to our assumption). So, a clear contradiction arises. This contradiction is due to our false assumption. Thus, $$a^2+2$$ i.e. $$n+2$$ is an imperfect square. Hence proved

• Welcome to MSE. For some basic information about writing mathematics at this site see, e.g., basic help on mathjax notation, mathjax tutorial and quick reference, main meta site math tutorial and equation editing how-to. Jul 27, 2019 at 12:36
• "Since the sum of a perfect square (here, a2) and an imperfect square (here, 2) is always an imperfect square, we know that the left hand side of the equation is an imperfect square and the right hand side of the equation is a perfect square (according to our assumption).". But, 4+5=9...? Aug 6, 2020 at 21:23