6. Pierino's calculator has a display, which initially shows the number 0, and two buttons: the +1 button, which adds 1 to the number on the display, and the $\times 3$ button, which multiplies the number on the display by 3. If the +1 button is pressed twice consecutively, the calculator explodes. If the calculator's display can hold at most 5 digits, how many numbers can Pierino obtain with an appropriate sequence of button presses (without making the calculator explode)?
(A) 2048
(B) 2187
(C) 4096
(D) 6561
(E) 66666
6. The answer is (A). The numbers that can be obtained with an appropriate sequence of +1 and $\times 3$ key presses without two consecutive +1s are all and only those that in base 3 are written with only the digits 0 and 1. Indeed, given such a number, to obtain it on the calculator, it suffices to scan from left to right the digits of its base 3 representation and press $\square+1$ for the first 1, then $\times 3$ each time a 0 is encountered, and $\times 3$ followed by +1 each time a 1 is encountered. In base 3, multiplying by 3 means shifting one position to the left. In this way, each string of 0s and 1s in base 3 is associated with a sequence of key presses that produces the corresponding number without causing the calculator to explode. The converse is also true: the key sequences involved are all and only those without two consecutive +1s, which would insert a 2 among the digits of the number. It remains only to count how many numbers with at most 5 digits in base 10 can be written in base 3 with only the digits 0 and 1. We note that $3^{11}>10^{5}$ while $3^{10}+3^{9}+\ldots+3^{0}=\frac{3^{11}-1}{2}<10^{5}$, so these are all and only those with at most 11 digits in base 3. Since there are 2 choices (0 and 1) for each digit, such numbers are $2^{11}=2048$. We observe that in this way, both the numbers with 11 digits (with the first digit equal to 1) and those with fewer than 11 digits (which correspond to those with 11 digits but with an appropriate number of leading zeros) have been counted.