# Does there exist $n\in\mathbb{N}$ such that $5^n-2^n$ is a perfect square?

I checked up to $$n\leq 100000$$ then found no example. So I suspect that there doesn't exist $$n\in\mathbb{N}$$ such that $$5^n-2^n$$ is a perfect square.
Then I tried to prove by modular arithmetic, but there seems no $$k$$ such that $$\{5^n-2^n \bmod k \mid n\in\mathbb{N}\}\cap\{n^2\bmod k\mid n\in\mathbb{N}\}=\emptyset$$.

• The only $n$ that yields a perfect square is $2$ in the Pythagorean Theorem and the number $2$ is not part of any Pythagorean triple. For this equation, the only solution is $n=0$. – poetasis Jan 7 at 20:04

Checking things modulo $$5$$ you can see that $$n$$ has to be even, as $$2$$ is not a square (and hence so are all odd powers). So say $$n = 2m$$. Then we can write $$5^n - 2^n = 5^{2m} - 2^{2m} = (5^m - 2^m)(5^m + 2^m).$$

Assume there exist $$n$$ such that we get perfect squares here. Then there is a minimal such $$n$$, that (due to laziness) we will in the following simply call $$n$$. Any prime that divides $$5^n - 2^n$$ must divide it to an even power of at least two (quickly exclude the case $$5^n - 2^n = 1$$ for completeness sake please). But if all these primes also divide $$5^m - 2^m$$ to an even power, then $$5^m - 2^m$$ is also a perfect square, a contradiction to the assumption that $$n$$ is minimal.
That means that there must exist a prime divisor $$p$$ of $$5^n - 2^n$$ that divides both $$5^m - 2^m$$ and $$5^m + 2^m$$. But then $$p$$ also divides the difference of the two, which is $$2^{m+1}$$, so $$p = 2$$.

But $$5^n - 2^n$$ is always odd, so $$p = 2$$ is not possible. Hence, we have found a contradiction to the assumption that any such $$n$$ exists.

• Nice and clean. – Wojowu Jan 27 '20 at 9:52

If $$n$$ is odd and greater than $$1$$ then $$5^n-2^n\equiv 5\pmod{8}$$, so it cannot be a square. If $$n$$ is even then $$5^{2m}-2^{2m}=a^2$$ leads to a primitive Pythagorean triple $$(a,2^m,5^m)$$. Since $$\mathbb{Z}[i]$$ is a UFD all the primitive Pythagorean triples involving a power of $$5$$ as greatest element depend on the real and imaginary part of $$(2+i)^{2m}$$. The real part is always odd, while the imaginary part $$a_m=\text{Im }(2+i)^{2m}$$ fulfills $$a_{m+2} = 6a_{m+1}-25 a_{m}$$ such that $$\nu_2(a_m)\leq \nu_2(m)+1.$$ It follows that, apart from the first cases, which can be checked by hand, $$a_m$$ cannot be equal to $$2^m$$ and there is no square of the form $$5^n-2^n$$.

One might note that $$5^n-2^n$$ is a base, and every new value of $$n$$ brings a new prime, previously not before seen. If some prime $$p$$ divides $$5^n-2^n$$ then it divides $$5^{pn}-2^{pn}$$ an additional time.

So $$5-2=3$$ which is not square. So we replace $$n$$ with $$3n$$, to get $$5^3-2^3 = 3^2 13$$. But the 13 is not square, so we have to replace $$n$$ with $$13n$$. Here we now introduce two very large coprime numbers, of which the larger is a multiple of 13.

It runs away as a power of exponentials.

• How do you show in the first line that $(5^n-2^n)$ has a prime divisor that doesn't divide $(5^i-2^i)$ for $i<n$? – Jam Jan 27 '20 at 10:41
• Because it's an algebraic base 5/2. See numberbase.fandom.com/wiki/Algebraic_Bases where i start writing this up. There is a new factor that does not divide any lesser value, in the size of $5^{\phi(n)}$, the euler totient power. – wendy.krieger Jan 27 '20 at 12:17
• I'm not the downvoter but I really don't see how this works. I agree that it works for $(5^n-2^n)$ up to at least $n=36$ (link) (beyond which, the numbers become too large to quickly factor) but the new factors are not all 'in the size of $5^{\phi(n)}$' or even the same order of magnitude. For $n=14$, we have a new factor of $1597$ but $5^{\phi(14)}=15625$. Or is this an asymptotic relation? Do you have any links to published proofs about this or is it all original work? – Jam Jan 27 '20 at 12:37
• The factor that appears at $n=14$ is 11179, which is 7*1597. The values of $5^n-2^n$ is cyclic over a period of 14, reletive to mod 49, but a period of 2 relative to mod 7. If you take the fractions 0/n to (n-1)/n, these will reduce according to the common factors of d/n. Fractions that don't reduce, like 1/m, will only occur when $m\mid n$. The new factors are then the product of $5 - 2 e^{2\pi\mathrm i * m/n}$ over m coprime and smaller than n. – wendy.krieger Jan 27 '20 at 13:22
• I see. Thank you for the clarification. Maybe you could add that to your answer and the numberbase.fandom page because I don't think it's obvious. – Jam Jan 27 '20 at 13:26