Find the number of positive integers less than or equal to $2017$ whose base-three representation contains no digit equal to $0$.
Solution 1
The base-$3$ representation of $2017_{10}$ is $2202201_3$. Because any $7$-digit base-$3$ number that starts with $22$ and has no digit equal to $0$ must be greater than $2017_{10}$, all $7$-digit numbers that have no digit equal to $0$ must start with $21$ or $1$ in base $3$. Of the base-$3$ numbers that have no digit equal to $0$, there are $2^5$ $7$-digit numbers that start with $21$, $2^6$ $7$-digit numbers that start with $1$, $2^6$ $6$-digit numbers, $2^5$ $5$-digit numbers, $2^4$ $4$-digit numbers, $2^3$ $3$-digit numbers, $2^2$ $2$-digit numbers, and $2^1$ $1$-digit numbers. Summing these up, we find that the answer is $2^5+2^6+2^6+2^5+2^4+2^3+2^2+2^1=\boxed{222}$.

Solution 2
Note that $2017=2202201_{3}$, and $2187=3^7=10000000_{3}$. There can be a $1,2,...,7$ digit number less than $2187$, and each digit can either be $1$ or $2$. So $2^1$ one digit numbers and so on up to $2^7$ $7$ digit.

Now we have to subtract out numbers from $2018$ to $2187$
Then either the number must begin $221...$ or $222...$ with  four more digits at the end
Using $1$s and $2$s there are $2^4$ options for each so:
$2+4+8+16+32+64+128-2*16=256-2-32=\boxed{222}$

Solution 3 (Casework)
Since the greatest power of $3$ that can be used is $3^6$, we can do these cases.
Coefficient of $3^6=0$: Then if the number has only $3^0$, it has 2 choices (1 or 2). Likewise if the number has both a $3^1$ and $3^0$ term, there are 4 choices, and so on until $3^5$, so the sum is $2+4+...+64=127-1=126$.
Coefficient of $3^6=1$: Any combination of $1$ or $2$ for the remaining coefficients works, so $2^6=64$. Why is this less than $126$? Because the first time around, leading zeroes didn't count. But this time, all coefficients $3^n$ of $n>2017$, so our answer is $126+64+32=\boxed{222}$.

See Also


[2017 AIME II](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II) ([Problems](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems) • [Answer Key](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Answer_Key) • [Resources](https://artofproblemsolving.comhttp://www.artofproblemsolving.com/Forum/resources.php?c=182&cid=45&year=2017))


Preceded by[Problem 3](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_3)

Followed by[Problem 5](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_5)


[1](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_1) • [2](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_2) • [3](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_3) • 4 • [5](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_5) • [6](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_6) • [7](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_7) • [8](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_8) • [9](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_9) • [10](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_10) • [11](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_11) • [12](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_12) • [13](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_13) • [14](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_14) • [15](https://artofproblemsolving.com/wiki/index.php/2017_AIME_II_Problems/Problem_15)


[ All AIME Problems and Solutions](https://artofproblemsolving.com/wiki/index.php/AIME_Problems_and_Solutions)

The problems on this page are copyrighted by the [Mathematical Association of America](https://artofproblemsolving.comhttp://www.maa.org)'s [American Mathematics Competitions](https://artofproblemsolving.comhttp://amc.maa.org). [AMC logo.png](https://artofproblemsolving.com/wiki/index.php/File:AMC_logo.png)