Finding coefficient $a_{1996}$ if $\;\prod_{n=1}^{1996}(1+nx^{3^n})=\sum_{n=0}^m a_nx^{k_n}$ This is from a math contest. I have solved it, but I'm posting it on here because I think that it would be a good challange problem for precalculus courses. Also, it's kind of fun.

Write the polynomial
$$
\prod_{n = 1}^{1996}\left(%
1 + nx^{3^{n}\rule{0pt}{3mm}}\right) =
\sum_{n=0}^{m}a_{n}\,x^{k_{n}}
$$
where the $k_{n}$ are in increasing order, and the $a_{n}$ are nonzero.

Find the coefficent $a_{1996}$.
 A: My attempt thanks to the hint by Thomas Andrews: The exponents K(n) of the powers of x in the polynomial are sums of powers of 3 each power being present in the sum at most ONE time.Therefore the powers of x represented in the ternary system will have the digits 0 and 1 (2 is not allowed since each power of 3 appears at most once in the sum). Therefore the ordering will be the  same as in the binary system , the difference being of course that the digits in the ternary system will correspond to powers of 3 whereas the digits in the binary correspond to powers of 2. The 1996th term has the following binary representation (if I am not wrong 1996=1024+512+256+128+64+8+4 in binary form= 11111001100   therefore the 1996th coefficient is the following product: 10X9X8X7X6X3X2 which corresponds to the product of the exponents of the powers of 2 that are present in the binary representation of 1996.It is worth noting that the 1996th coefficient is the 1996th NON ZERO coefficient In between there are many zero coefficients which correspond to the powers of x which have a ternary system representation comprising the digit 2.
