Problem

Source: Polish National Olympiad 2015 2nd round, p5

Tags: algebra, number theory, combinatorics



Let $n$ be a positive integer. Determine the number of sequences $a_0, a_1, \ldots, a_n$ with terms in the set $\{0,1,2,3\}$ such that $$n=a_0+2a_1+2^2a_2+\ldots+2^na_n.$$