Find the number of polynomials $P(x)$ with coefficients $0,1,2,3$ such that $P(2) = n$.

combinatoricscontest-mathpolynomials

Find the number of polynomials $P(x)$ with coefficients $0,1,2,3$ such that $P(2) = n$.

Only what I currently know is that I should consider polynomials with the smallest degree $k$, where $k$ is first integer such that
$$ 3 \cdot (1 + 2 + 4 + … + 2^k) = 3 \cdot \frac{2^{k+1}-1}{1} \ge n $$
$$ 2^{k+1} \ge \frac{n}{3}+1 $$
$$ k \ge \log_2(\frac{n}{3}+1) – 1 $$

But what should be done next? I don't see a pattern here.

Best Answer

Let your polynomial be $P(x) = \sum_{k=0}^n c_i x^i$. Let $A_k$ be the sets of nonnegative integers $i$ such that $c_i = k$, $k=0,1,2,3$. Thus $$ \eqalign{n &= \sum_{i \in A_1} 2^i + 2 \sum_{i \in A_2} 2^i + 3 \sum_{i \in A_3} 2^i\cr &= \sum_{i \in A_1 \cup A_3} 2^i + 2\sum_{i \in A_2 \cup A_3} 2^i}$$ Given any nonnegative integers $a,b$ such that $n = a + 2 b$, we can find $A_0, A_1, A_2, A_3$ such that $a = \sum_{i \in A_1 \cup A_3} 2^i$ and $b = \sum_{i \in A_2 \cup A_3} 2^i$, namely $A_0$ is the set of $i$ such that the base-2 digit in the "$2^i$" place for both $a$ and $b$ are $0$, $A_1$ where the digit is $1$ for $a$ and $0$ for $b$, $A_2$ where the digit is $0$ for $a$ and $1$ for $b$, $A_3$ where the digit is $1$ for both.

Now count how many ways there are to write $n=a+2b$...