# Not quite binary

Find the number of ways of expressing $$n=2017$$ as

$a_0 + a_1 2 + a_2 2^2 + a_3 2^3 + \cdots + a_k 2^k$

$$a_i \in \{0,1,2\}$$.

×