# Make a certain number with an unusual calculator

The Kasio Kool-Kalk™ is a poorly-designed calculator with only two buttons, labelled $[A]$ and $[B]$.

• Pushing $[A]$ replaces the currently displayed number $x$ with $2-\frac{1}{x}$.
• Pushing $[B]$ replaces the currently displayed number $x$ with $1+\frac{1}{x-1}$.

If a button press results in division by zero, the calculator bursts into flames.

The display currently shows $2$. Find a sequence of buttons to turn this into $\frac{1003}{100}$.

• I wasn't quite sure if [blackboard] fit here - it seems like a "blackboard problem" with a capacity of 1 number. Feel free to remove if you think it doesn't fit. – Deusovi Apr 8 '16 at 21:51
• I think the blackboard tag is a good fit. – Julian Rosen Apr 8 '16 at 21:51

Let $A(x)=2-\frac{1}{x}$ and $B(x)=1+\frac{1}{x-1}$. Notice:

$$A(B(x))=2-\frac{1}{1+\frac{1}{x-1}}=2-\frac{x-1}{x}=1+\frac{1}{x}$$so$$B(A(B(x)))=1+\frac{1}{1+\frac{1}{x}-1}=1+x$$so by pressing $BAB$ we can increase the number by 1. If we press $AA$ we have $\frac{4}{3}$, and then we can add 1 32 times to get $\frac{100}{3}$. Pressing $BA$ then gives $\frac{103}{100}$, and $BAB$ 9 more times results in $\frac{1003}{100}$. However,$$B(B(x))=1+\frac{1}{1+\frac{1}{x-1}-1}=x$$so we can skip pressing $B$ twice in a row: $BAB$ repeated $n$ times becomes equivalent to $B$, then $A$ $n$ times, then $B$.

In total, the sequence of button presses is

$A^2BA^{33}BA^9B$.

(One continued fraction representation of $\frac{1003}{100}-1$ is $[9;33,2,1]$. This is not a coincidence, which can be explained if you consider how the operations affect $x-1$.)

I wanted to post my solution as well, because it looks a little diffferent than f'''s.

If we press $[A]$ repeatedly we see $\frac{3}{2}$, $\frac{4}{3}$, $\frac{5}{4}$, $\ldots$, and indeed $[A]$ takes $1+\frac{1}{n}$ to $1+\frac{1}{n+1}$. This suggests looking at the quantity $y:=\frac{1}{x-1}$, where $x$ is the displayed number. The conversion the other way is $x=1+\frac{1}{y}$.

So $[A]$ takes $y$ to $y+1$, and you can check that $[B]$ takes $y$ to $\frac{1}{y}$. These operations can be used to build up a continued fraction. The initial value is $y=1$, and the desired value is $y=\frac{100}{903}$, which has continued fraction $$\frac{100}{903}=\frac{1}{9+\frac{1}{33+\frac{1}{3}}}.$$ We need to add $2$ to $y$, take the reciprocal, add $33$, take the reciprocal, add $9$, and take the reciprocal, so the sequence of buttons is

$A^2BA^{33}BA^9B$.

To come up with the operations $A$ and $B$, I started with $y\mapsto y+1$ and $y\mapsto \frac{1}{y}$ (with continued fractions in mind), and conjugated by an arbitrarily transformation $x=1+\frac{1}{y}$.