# Are there any two squares with a distance of a power of 2 between them?

I was working with Pythagorean triples and found a formula to generate Pythagorean triples. I am pretty sure every Pythagorean triple falls under my formula. This formula is: If $a$, $x$, and $n$ are all integers greater than zero, and $x = (2a + 1)n$, then the set $\{x,\frac{x^2 - n^2}{2n}, \frac{x^2 + n^2}{2n}\}$ is a Pythagorean triple. After playing around with these numbers for awhile I figured out that if I am correct, no two squares are a distance of a power of $2$ apart. Could someone confirm this to be true?

• NB $2^3 = 3^2 - 1^2$ and $2^4 = 5^2 - 3^2$. – Travis Willse Jan 29 '16 at 13:14
• $5^2-3^2=4^2$... – abiessu Jan 29 '16 at 13:16
• Multiplying all the numbers in your triple by $2na$ and restricting $x, n$ to be coprime, one even, the other odd, generates all Pythagorean Triples. – Element118 Jan 29 '16 at 13:17
• You might be interested in reading en.wikipedia.org/wiki/Pythagorean_triple and en.wikipedia.org/wiki/… – CiaPan Jan 29 '16 at 14:02

More generally, if $c=2^{n-2}+1$ and $a=2^{n-2}-1$ then $c^2-a^2=2^{n}$.
When $n$ is even, $a=u^2-1, b=2u, c=u^2+1$ is a Pythagorean triple, for $u=2^{(n-2)/2}$, and $c^2-a^2=b^2=2^n$.
It is true for the legs of a Pythagorean triple, other than $2^0=1$, of course, under the condition that the legs are relatively prime.
Alternatively, it is definitely true that the difference cannot be an odd power of $2$.