# Solve the diophantine equation $5^m + n^2=3^p$

Solve the diophantine equation: $5^m + n^2=3^p$ where $m,n,p \in \mathbb{N}-\{0\}$

One solution is $m=1,n=2,p=2$. Now, applying modulo 4:

$1 + 0 = (-1)^p \mod 4 \tag 1$ or $1 + 1 = (-1)^p \mod 4 \tag 2$

But only (1) is possible, therefore both $n, p$ are even.

Also, applying modulo 3:

$(-1)^m + n^2 = 0 \mod 3 \tag 3$ therefore $m$ is odd and $n=3k \pm 1$

I could not get any further.

• Well, writing $p=2k$ we get $5^m=(3^k+n)(3^k-n)$ whence $3^k+n=5^a$, $3^k-n=5^b$ with $a+b=m$. Adding shows that $2\times 3^k=5^a+5^b$ whence one of $a,b$ must equal $1$. So you need a solution to $5^m+1=2\times 3^k$. That makes it look like the Catalan problem but I don't know if the factor of $2$ has been considered by anyone. – lulu Dec 24 '17 at 14:18
• Note: typo in my first comment. I meant that one of $5^a,5^b$ had to be $1$ so one of $a,b$ must be $0$. – lulu Dec 24 '17 at 14:28
• @lulu It's a good development – user261263 Dec 24 '17 at 14:46
• @lulu A little more to add: $m$ must be odd to give a factor $3$ and then you can extract a factor $5+1=6$. The remaining part is equivalent to $1$ modulo $4$ which means that $k$ must also be odd and also equivalent to $1$ modulo $5$ which means that $k$ must be $4a+1$ – Mark Bennet Dec 24 '17 at 14:52

Following lulu, to prove there are no solution with $p\geq 3$, we only need to prove the equation $$2(3^k) - 5^m = 1$$ has no solution with $k\geq 2$.
Note that $5$ is a primitive root modulo $3^2$, hence $5$ is a primitive root modulo $3^n$ for all positive integer $n$. Thus $$5^m \equiv -1 \pmod{3^{k}} \implies \frac{\phi(3^{k})}{2}\mid m \implies 3^{k-1}\mid m$$ Therefore $(1)$ implies, for some $r\geq 1$ $$1 = 2({3^{k}}) - 5^{r(3^{k-1})} \leq 2({3^{k}}) - {5^{{3^{k-1}}}}$$ a contradiction, because RHS is negative when $k\geq 2$.
Therefore, the only positive integer solution of $5^m + n^2=3^p$ is $m=1,n=2,p=2$.