TITLE: Finding all integer solutions of $5^x+7^y=2^z$
QUESTION [21 upvotes]: Find all integers $x,y,z$ such that $5^x+7^y=2^z$.

This one comes from an online contest that I arranged some years ago, and I can assure that a completely elementary solution exists.

REPLY [7 votes]: A "completely elementary solution":
We shall use only modular arithmetic.
Since $\gcd(2, 5, 7)=1$, $x, y, z$ are non-negative.
If $x=0$, then $1+7^y=2^z$. If $z \geq 4$, taking $\pmod{16}$ gives $1+7^y \equiv 0 \pmod{16}$, a contradiction. Thus $z \leq 3$, and checking gives the solutions $(x, y, z)=(0,0, 1), (0, 1, 3)$.
Otherwise $x \geq 1$, so $2^z=5^x+7^y \geq 5+1$, so $z \geq 2$. Taking $\pmod{4}$ gives $1+(-1)^y \equiv 0 \pmod{4}$, so $2 \nmid y$, implying that $y \geq 1$. We have $2^z=5^x+7^y \geq 12$, so $z \geq 4$.
Taking $\pmod{16}$, we get $5^x+7^y \equiv 0 \pmod{16}$, so $x \equiv 2 \pmod{4}, 2 \nmid y$. 
Taking $\pmod{5}$, we get $2^y \equiv 7^y \equiv 2^z \pmod{5}$, so $y \equiv z \pmod{4}$.
If $y \equiv z \equiv 3 \pmod{4}$, then taking $\pmod{13}$, we get $-1+7^y \equiv 5^x+7^y \equiv 2^z \pmod{13}$. We have $7^y \equiv 5, 6, 2 \pmod{13}, 2^z \equiv 8, 11, 7 \pmod{13}$, which is impossible.
Thus $y \equiv z \equiv 1 \pmod{4}$. Again taking $\pmod{13}$, we get $-1+7^y \equiv 5^x+7^y \equiv 2^z \pmod{13}$. We have $7^y \equiv 7, 11, 8 \pmod{13}, 2^z \equiv 2, 6, 5 \pmod{13}$, so $y \equiv 1 \pmod{3}, z \equiv 2 \pmod{3}$.
Taking $\pmod{7}$, we get $2^x \equiv (-2)^x \equiv 5^x \equiv 2^z \pmod{7}$, so $x \equiv z \equiv 2 \pmod{3}$. 
Combining the information so far, we have $(x, y, z) \equiv (2, 1, 5) \pmod{12}$. For convenience, let us write $x=12a+2, y=12b+1, z=12c+5, a, b, c \geq 0$, so the equation becomes:
$$5^{12a+2}+7^{12b+1}=2^{12c+5}$$
Now so far everything we have done still allows for the solution $(2, 1, 5)$. 
Let us consider $b \geq 1$ first. Then taking $\pmod{49}$, we get 
$2^{-(6a+1)} \equiv 25^{6a+1} \equiv 5^{12a+2} \equiv 2^{12c+5} \pmod{49}$, so $15^{2c+a+1} \equiv 2^{12c+6a+6} \equiv 1 \pmod{49}$. Thus $7 \mid 2c+a+1$.
Now let's take $\pmod{43}$. We shall get a contradiction. We have $5^{12} \equiv -2 \pmod{43}, 7^{12} \equiv 1 \pmod{43}, 2^{12} \equiv 11 \pmod{43}$. Thus $25(-2)^a+7 \equiv 32(11)^c \equiv 32(-2)^{5c} \equiv 32(-2)^{a+1} \equiv (-64)(-2)^a \pmod{43}$. This gives:
$$89(-2)^a \equiv -7 \pmod{43}$$
$$3(-2)^a \equiv 36 \pmod{43}$$
$$(-2)^a \equiv 12 \pmod{43}$$
But $(-2)^a \equiv 41, 4, 35, 16, 11, 21, 1 \pmod{43}$, so we get a contradiction.
Therefore $b=0$, and we get:
$$5^{12a+2}+7=2^{12c+5}$$
By now I am really tempted to just say "This is a special case of the Ramanujan square equation, for which solutions are known." Nevermind. Let's continue. 
If $c=0$, then $a=0$, and we get the solution $(x, y, z)=(2, 1, 5)$.
Otherwise $c \geq 1$. Taking $\pmod{64}$, we get $25(17^a)+7 \equiv 5^{12a+2}+7 \equiv 0 \pmod{64}$. Thus $a \equiv 2 \pmod{4}$. Put $a=4d+2$, so we get 
$$5^{48d+26}+7=2^{12c+5}$$
Taking $\pmod{17}$, we get $16 \equiv 5^{10}+7 \equiv 5^{48d+26}+7 \equiv 2^{12c+5} \equiv 32(-1)^c \pmod{17}$, giving a contradiction.
To conclude, the only solutions are $(x, y, z)=(0, 0, 1), (0, 1, 3), (2, 1, 5)$.