Finding $a_{1996}$ if $\prod_{n=1}^{1996}(1+nx^{3^n})= 1+a_1x^{k_1} + a_2x^{k_2} + \cdots + a_mx^{k_m}$

What powers of $x$ appear as a term in the expression? Of course $x^0$. And $x^3$. More generally, any positive integer that can be built from summing powers of $3$ with no repeats. $$x^0,\overset{1\text{st}}{x^3},\overset{2\text{nd}}{x^9},\overset{3\text{rd}}{x^{12}},\overset{\cdots}{x^{27}},x^{30},x^{36},x^{39},\ldots$$ In base 3, these are numbers that use only 0 and 1 for their digits, with a 0 in the "ones" place. $$x^0,x^{10},x^{100},x^{110},x^{1000},x^{1010},x^{1100},x^{1110},\ldots$$ So what would be the 1996th term's power of $x$? In binary, 1996 is $$11111001100$$

So we are looking for $x^{111110011000}$ but the exponent is in base 3. It is built from multiplying $$x^{3^{11}}x^{3^{10}}x^{3^{9}}x^{3^{8}}x^{3^{7}}x^{3^{4}}x^{3^{3}}$$

So its coefficient is $$11(10)(9)(8)(7)(4)(3)=665280$$