TITLE: The Keys problem
QUESTION [8 upvotes]: Another challenge:
A calculator has two special keys:

A key transforms a number x in the number 2x.
B key transforms a number x in the number 2x - 1.

Is it true that if you start with any positive integer, it is possible to press a special key sequence in such a way as to obtain finally the fifth power of an integer?
By simple inspection one realizes that the powers of 2 greater than 1 you can get a fifth power using the A key, but will be possible with other numbers?

REPLY [2 votes]: First, we characterize the space we're working with.
Let $X_n$ denote the set of $n$-tuples with entries in $\{A,B\}$ and consider the sets $$G_k=\bigcup_{j=1}^k\left\{\left(\prod_{i=1}^jx_k\right)m:x\in X_n\right\}\subseteq \mathbb{Z}[m]$$
Now let's form $\bar G=\bigcup_{k=1}^\infty G_k$.

Claim. $$\bar G = \bigcup_j\left\{2^jm-2^{j}+1,\ldots, 2^jm\right\}.$$
Proof. We'll prove this by induction.  Write $L_j=\left\{2^jm-i:i=\{0,\ldots,2^j-1\}\right\}$.  The base case is trivial. Now, $$\begin{eqnarray*}A L_n&=&\left\{2\times (2^nm-i):i\in\{0,\ldots,2^n-1\}\right\}\\&=&\left\{2^{n+1}m-i:i\in\{0,2,\ldots,2^{n+1}-2\}\right\}\end{eqnarray*}$$
  and $$\begin{eqnarray*}B L_n&=&AL_n-1\\&=&\left\{2^{n+1}m-i:i\in\{1,3,\ldots,2^{n+1}-1\}\right\}\end{eqnarray*}$$
  so $$L_{n+1}=AL_n\cup BL_n.$$

If we define $\varphi_n:\bar G \rightarrow \mathbb{Z}$ by $\varphi_n(f)=f(n)$ and $g(x)=x^5$, we want to prove that, for every $n\in \mathbb{N}$, $$\varphi_n[\bar G]\cap g[\mathbb{Z}]\ne\emptyset.$$
Our strategy will be to find a big enough $j$ so that $\varphi_n[L_j]$ is large enough that it must contain a fifth root (so that $g^{-1}(x)$ is an integer for some $x\in L_j$). Of course we can find such a number so long as $$f_m(j)= g^{-1}\left(2^jm\right)-g^{-1}\left(2^j(m-1)+1\right)\geq 1$$
which, by some relatively messy calculations, is true when $g(x)=x^5$.  I've left $g$ arbitrary to make the point that not just fifth roots, but in fact any roots suffice, as well as any increasing polynomial function.