Consider the number of integer partitions $p(n)$ of $n$ whose generating function is $$\sum_{n\geq0}p(n)\,x^n=\prod_{k\geq1}\frac1{1-x^k}.$$ Also, the number of partitions into distinct parts $Q(n)$ of $n$ whose genertaing function is $$\sum_{n\geq0}Q(n)x^n=\prod_{k\geq1}(1+x^k).$$ Expand the ratio of these two generating functions so that $$\sum_{n\geq0}a(n)x^n=\prod_{k\geq1}\frac{1+x^k}{1-x^k}.$$
QUESTION. Why is $a(n)\equiv 2\,\, (\text{mod}\, 4)$ iff $n$ is a perfect square, for $n\geq1$?