Find all pairs of positive integers $(a,b)$ such that $2^a+5^b$ is a perfect square.
if $2^a+5^b=w^2$, then $2^a \equiv w^2 \pmod 5$. This implies that $2\mid a$. So let $c\in\Bbb{N}\space|\space 2c=a$. $$2^{2c}+5^b=w^2$$ $$5^b=w^2-2^{2c}$$ $$5^b=(w-2^c)(w+2^c)$$ both $w-2^c$ and $w+2^c$ are both powers of $5$ so $\exists \space s,t\in\Bbb{N}\space|\space b=s+t, s>t,\space 5^s=w+2^c,5^t=w-2^c$ $$5^s=w+2^c\space\space\space(1)$$ $$5^t=w-2^c\space\space\space(2)$$ subtracting $(2)$ from $(1)$ we get $$5^s-5^t=2^{c+1}\space\space\space(3)$$ $$5^t(5^{s-t}-1)=2^{c+1}\space\space\space(4)$$ $5\nmid 2^{c+1}$ so $t=0$ and $s=b$. Therefore $$5^b-1=2^{c+1}\space\space\space(5)$$ $$5^b-5+2^2=2^{c+1}\space\space\space(6)$$ $$5^b-5=2^{c+1}-2^2\space\space\space(7)$$ $$5(5^{b-1}-1)=2^2(2^{c-1}-1)\space\space\space(8)$$ $5\mid $lhs of (8) $\Rightarrow$ $5\mid $rhs of (8). $5\nmid 2^2$ so $5 \mid 2^{c-1}-1 \Rightarrow 4 \mid c-1$
lhs of (8) $\equiv 0,20,27\pmod {31}$ and rhs of (8) $\equiv 0,4,12,28,29\pmod {31}$
The only way for the equation to be equal is if both sides are divisible by 31.
$31\nmid 2^2$ therefore $31\mid 2^{c-1}-1 \Rightarrow 5 \mid c-1$
Combining both of the facts that $4 \mid c-1$ and $5 \mid c-1\Rightarrow 20\mid c-1\Rightarrow 25 \mid 2^{c-1}-1\Rightarrow 25\mid $rhs of (8)$\Rightarrow 25\mid $lhs of (8) $\Rightarrow 5\mid 5^{b-1}-1\Rightarrow b=1$
plugging in $1$ for $b$ in $(5)$ implies that $c=1\Rightarrow a=2$
the first solution is $a=2$, $b=1$, $w^2=9$
Edit: In the beginning of the proof I assumed that $2^a\equiv w^2 \pmod 5$. This is true iff $b\neq 0$.
If $b=0$ then $2^a+1=w^2$ $$2^a+1=w^2$$ $$2^a=w^2-1$$ $$2^a=(w-1)(w+1)$$ both $w-1$ and $w+1$ are both powers of $2$ so $\exists \space u,v\in\Bbb{N}\space|\space a=u+v, u>v,\space 2^u=w+1,2^v=w-1$ $$2^u=w+1\quad(9)$$ $$2^v=w-1\quad(10)$$ subtracting $(10)$ from $(9)$ we get $$2^u-2^v=2\quad(11)$$ $$2^v(2^{u-v}-1)=2\quad(12)$$ This implies $v=1$ and both sides of (12) can be divided by 2 $$2^{u-1}-1=1\quad(13)$$ $$2^{u-1}=2\quad(14)$$ $$u-1=1\quad(15)$$ $$u=2\quad(16)$$ This gives the second solution $a=3$, $b=0$, $w^2=9$
Edit 2: too long for comment, answering Prathmesh's question from the comment below
After getting to equation to $(8)$ I knew that if I could show that $5 \mid 5^{b-1}-1$ then there would only be one solution to that portion of the problem. Working backwards $25 \mid 2^{c-1}-1$. powers of $2$ have a cycle of $20 \pmod{25}$. So $25 \mid 2^{c-1}-1$ iff $20 \mid c-1$. I already had $4 \mid c-1$ from the fact that both sides of $(8)$ are divisible by $5$. So I needed a mod that produces cycle that is a multiple of $5$ in powers of $2$. In general if a mod will produce a cycle $x$ if the mod is divisible by a sufficiently large power of of $x$ or is divisible by a prime factor that is of the form $xk+1$. So the mod in this case needs to have a sufficiently large power of of $5$ or has a prime factor of the form $5k+1$. Since I am trying to prove that the rhs is divisable by $25$ I can't use powers of $5$ so I am left with numbers that have a prime factor of the form $5k+1$. All primes except $2$ are odd so I can just look at numbers of the form $10k+1$. So I first tried $11$ but both sides can be $\equiv 1,3,4,5,9\pmod{11}$. $21$ has a prime factorization of $3$ and $7$ neither of which is of the form $10k+1$. so then I tried $31$.
If $2^a+5^b = m^2$, then $m^2\equiv 0, 1, 4\pmod{5}$. $0$ is impossible since $2^a$ is never divisible by 5, so $2^a+5^b\equiv 2^a \equiv 1, 4\pmod{5}$. This implies that $a$ is even, say $a=2k$. This gives $5^b = m^2-2^{2k} = (m-2^k)(m+2^k)$, which implies that both $m-2^k$ and $m+2^k$ are powers of $5$, say $$m-2^k = 5^r,\ m+2^k=5^s, r<s\quad\Rightarrow\quad 2^{k+1} = 5^s-5^r.$$ But $5^s-5^r$ is divisible by 5 for $r>0$, so it cannot be a power of two unless $r=0$.
Thus any solution must have $m=2^k+1$, $m+2^k = 5^b$, so that $5^b = 2^{k+1}+1$, or $5^b-2^{k+1}=1$. By Mihăilescu's theorem, either $b\le 1$ or $k+1\le 1$. Since $b$ is a positive integer, we get $b=1$, whence $2^{k+1}=4$ and $k=1$, so $a=2$.