Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
So you know the answer to your question? Hey, that's not fair :) – Lord Soth Apr 1 '13 at 23:36
$\,(2,1,5)\,,\,(2,2,6)\,$ ... – DonAntonio Apr 1 '13 at 23:36
$(2,2,6)$ is not a solution :O – Paolo Leonetti Apr 1 '13 at 23:41
Yeah, it is not: it's a pity $\,2^6\neq 74\,$....tsk,tsk,tsk. Well, at least the first one is. :) – DonAntonio Apr 1 '13 at 23:44
That happens :P – Paolo Leonetti Apr 1 '13 at 23:49
up vote 7 down vote accepted

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:


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:


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


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)$.

share|cite|improve this answer
That is almost the same of mine, well done: +1. – Paolo Leonetti Apr 3 '13 at 16:20

I'm going to post a possible proof and maybe with some important mistakes,please check it and let me see where is wrong.

(1)$x,y,z>0$. Since $Z(\sqrt{-7})$ is an Euclidean domain,the factorization is unique,and the elements are those $z=a+bt$, and $N(z)=a^2+ab+2b^2$,where $t=\frac{1+\sqrt{-7}}2$.The units are $z=±1$,and $2=t(1-t)$.

$5^x+7^y=2^z$,if $z>2$ then $$5^x+7^y\equiv 1^x+(-1)^y\equiv 0\pmod4$$ hence $y\equiv 1\pmod2$. and $$5^x+7^y\equiv 5^x+(-1)^y\equiv 5^x-1\equiv 0\pmod8$$ hence $x\equiv 0\pmod2$. $$5^x+7^y-2^z\equiv(-2)^x+0-2^z\equiv2^x-2^z\equiv 0\pmod7$$ hence $x\equiv z\pmod3$. $$5^x+7^y-2^z \equiv 0+2^y-2^z \equiv 0\pmod5$$ hence $y\equiv z\pmod 4$.

We only need $x\equiv 0\pmod2,y\equiv 1\pmod2$. Let $u=5^{x/2},v=7^{(y-1)/2},w=z-2$, here $w>0$,and $u^2+7v^2=2^{w+2}$. We get $$(u+v(2t-1))*(u-v(2t-1))=2^{w+2}$$ $$(\frac{u-v}2+vt)*(\frac{u+v}2-vt)=2^w=t^w*(1-t)^w$$ here $t$ and $1-t$ are both prime in $Z(\sqrt{-7})$.

Since $\frac{u-v}2+vt=\frac{5^{x/2}-7^{(y-1)/2}}2+7^{(y-1)/2}t$, and $7^{(y-1)/2}$ is odd, so $GCD(\frac{u-v}2+vt,\frac{u+v}2-vt)=1$ hence $$\frac{u-v}2+vt=t^w,\frac{u+v}2-vt=(1-t)^w$$ or change the order(we can replace $v$ with $-v$,so it doesn't matter). Hence $$u=t^w+(1-t)^w,v=\frac{t^w-(1-t)^w}{2t-1)}$$ as $y>1$ , $v>1$ and $u\equiv0 \pmod 5,v\equiv0 \pmod 7$.

With a little compute,we get $w\equiv 21 \pmod{42}$.However,it leads to $u\equiv0 \pmod 13$,which is a contradiction. So $y$ cannot great than $1$.

If $y=1$ then $5^x+7=2^z$,which is Ramanujan equation:$u^2+7=2^z$,so $x=2,z=5$.

(2)If $x=0$,then $1+7^y=2^z$.if $z>3$,then $1+7^y\equiv 0\pmod{16}$,that's impossible.

In the case $z<=3$,we have $(x,y,z)=(0,0,1)(0,1,3)$.

If $x>0$,as we have proved in (1),$y$ is odd, hence $y>0$,and $z>0$.

So $(x,y,z)=(0,0,1)(0,1,3)(2,1,5)$.

share|cite|improve this answer
Thumb up. You got the non-elementary solution that I did know, but really in a few. Just a thing to avoid a reference: you can skip the Ramanujan equation, just looking in sequence at modules $25$, $32$ and $17$. Just to complete, at this point if $\min\{x,y,z\}<0$ then also $\max\{x,y,z\}<0$, and getting immediately a contradiction. – Paolo Leonetti Apr 2 '13 at 11:10

I could partially solve this.

$5^x + 7^y = 2^z$

Firstly, we will write down the last digits of the powers of $5,7,2$ respectively.

For any power of '$5$' the last digit is always $'5'$.

$5, 5, 5, 5$

For powers of '$7$' the last digits are as follows and they repeat in cycles of $4$:

$7, 9, 3, 1$

For powers of '$2$' the last digits are as follows and they repeat in cycles of $4$:

$2, 4, 8, 6$

So By adding the term ending in '$5$' to that ending in '$7$' will give '$2$' and this is the case for the other $3$ terms.

Hence, if y = $(4m+1)$ , then z = $(4n+1)$.

Therefore, the difference between $y$ and $z$ is always a multiple of $4$. Also one must keep in mind that $2^z - 7^y$ should always be positive because $5^x$ can never be negative.

So $z=5,y=1$ satisfies this and this leads to the solution $x=2,y=1,z=5$ or $(2,1,5)$.

There clearly exist no other solution for higher values of '$z$', but i am unable to prove it.

share|cite|improve this answer
I have taken the liberty of very slightly editing this because I found the terminology confusing at first. – Potato Apr 2 '13 at 5:16
If you remove the "clearly" the problem begins ;) To sum up, lsp just proved that: "If $(x,y,z)$ is a solution then $4\mid z-y$". – Paolo Leonetti Apr 2 '13 at 7:17
@PaoloLeonetti: But $(0,0,1)$ and $(0,1,3)$ violate that. – Ross Millikan Apr 2 '13 at 15:36
Indeed it was assumed implicitely that $x\ge 1$; in rough terms, half problem is missed, i.e. all cases $x\le 0$; except that, we are talking about trivial cases.. I am still waiting if someone finds a elementary solution different from mine – Paolo Leonetti Apr 2 '13 at 17:29
@PaoloLeonetti Why don't you go ahead and post the elementary solution you do know, then? – Potato Apr 3 '13 at 1:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.