I want to find all integer solutions of $3^a + 7 = 2^b$

I have found (by brute force) the two solutions
$3^0 + 7 = 2^3$ and
$3^2 + 7 = 2^4$

but I want to see if there are more solutions. I have found that if (b mod 3) = b' then (a mod 6) must be 2b', and that (a mod 4) can't be 1, but that's as far as I get and I have no clue how to make progress.
Any ideas? TIA

  • 1
    $\begingroup$ I am pretty sure someone will find a complete proof, but $3^a+7$ is upto $a=10^5$ only a perfect power if $a=0$ or $a=2$ giving your solutions (brute force with PARI/GP) . It is very unlikely that there are more. Note that in general such diophantine equations are extremely difficult to solve or even out of reach , this particular one is probably not of this kind. $\endgroup$
    – Peter
    Apr 8, 2022 at 7:54
  • 1
    $\begingroup$ Also see math.stackexchange.com/questions/1941354/… $\endgroup$
    – R.P.
    Apr 8, 2022 at 9:37
  • 4
    $\begingroup$ Does this answer your question? Elementary solution of exponential Diophantine equation $2^x - 3^y = 7$. Found from RP_'s comment above. $\endgroup$ Apr 8, 2022 at 9:48

1 Answer 1


A negative $b$ or a negative $a$ cannot lead to a solution. So $a,b\ge 0$. For $a=0$ we obtain OP's first solution $3^0+7=2^3$. Else $a\ge 1$. Then taken modulo $3$ the powers of two ($2\equiv -1\ [3]$) for $b=0,1,2,3,\dots$ are $1,-1,1,-1,\dots$, so the involved two-power $b$ is even, $b=2B$ for some natural $B$.

Since $b\ge 3$, considering the L.H.S. modulo four, we have for $a=0,1,2,3,\dots$ the values $1+7, -1+7, 1+7, -1+7,\dots$ so the involved three-power is even, $a=2A$ for some natural $A$. We rewrite now the given relation as follows: $$ 7 = 2^a-3^b=2^{2A}-3^{2B}=(2^A-3^B)(2^A+3^B)\ . $$ This is possible only when $(2^A-3^B)=1$ and $(2^A+3^B)=7$, so $2^A=(7+1)/2=4$, and $3^B=(7-1)/2=3$, leading to the second solution given by the OP.


  • $\begingroup$ FYI, this uses basically the same method as the accepted answer of the duplicate question. $\endgroup$ Apr 8, 2022 at 9:51
  • 1
    $\begingroup$ @JohnOmielan Yes, it is the only natural idea in such situations. Unfortunately i started typing the answer. We may vote to close the question for the reason of being a duplicated question. (... voted for it last seconds) $\endgroup$
    – dan_fulea
    Apr 8, 2022 at 9:54

Not the answer you're looking for? Browse other questions tagged .