# For which integers $m$ is there a solution to $3^y m - 2^x = 1$?

This self-answered question is motivated by a recent question asking whether for every $$m$$ there is a solution $$(x, y)$$ of integers to the equation $$3^y m - 2^x = 1$$ for every odd positive integer $$m$$. As the answers there show there is not---the easiest way to see this is to recall that the only solutions to $$3^{y'} - 2 x = 1$$ have $$y' \leq 2$$, so for $$m = 3^k$$, $$k > 2$$, the resulting equation $$3^{y + k} - 2^x = 1$$ has no solutions. But this raises the natural question:

For which integers $$m$$ is there a solution $$(x, y)$$ in positive integers to the equation $$3^y m - 2^x = 1 \,?$$

Reducing modulo $$3^y$$ and rearranging leaves $$2^x = -1 \pmod {3^y} .$$ On the other hand, since $$2$$ is a primitive root modulo $$3^1, 3^2$$, it is a primitive root modulo $$3^y$$ for all $$y \geq 1$$. So, since $$(\Bbb Z / (3^y \Bbb Z))^\times$$ has order $$\phi(3^y) = 2 \cdot 3^{y - 1}$$, for fixed $$y$$ the $$x$$ satisfying the above congruence are exactly those of the form $$x = \frac{\phi(3^y)}{2} (2 k + 1) = 3^{y - 1} (2 k + 1) , \qquad k \in \Bbb Z_{\geq 0} .$$ Thus, substituting in the original equation and solving for $$m$$ gives that the $$m$$ that occur are exactly those of the form $$\color{#df0000}{\boxed{m = \frac{2^{3^{y - 1} (2 k + 1)} + 1}{3^y}, \qquad k \geq 0, y \geq 1}} .$$ The solutions with $$\color{#df0000}{m} < 1000$$ give the equations \begin{alignat}{4} 3^1 \cdot \color{#df0000}{1} - 2^1 &= 1 & 3^2 \cdot \color{#df0000}{1} - 2^3 &= 1 & 3^1 \cdot \color{#df0000}{3} - 2^{3\phantom{1}} &= 1 \\ 3^1 \cdot \color{#df0000}{11} - 2^5 &= 1 & 3^3 \cdot \color{#df0000}{19} - 2^9 &= 1 & 3^1 \cdot \color{#df0000}{43} - 2^{7\phantom{1}} &= 1 \\ 3^2 \cdot \color{#df0000}{57} - 2^9 &= 1 &\qquad 3^1 \cdot \color{#df0000}{171} - 2^9 &= 1 &\qquad 3^1 \cdot \color{#df0000}{683} - 2^{11} &= 1 . \end{alignat} The smallest $$\color{#df0000}{m}$$ giving a solution of the form $$(x, 4)$$ yields $$3^4 \cdot \color{#df0000}{1\,657\,009} - 2^{27} = 1 .$$ Incidentally, the sequence $$1, 3, 11, 19, 43, \ldots$$ of $$\color{#df0000}{m}$$ that admit solutions does not appear in the OEIS.