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$?
> 
> 
> 



Congruence modulo 4 for a generating function leads to perfect squares?
$$\frac{1+x^k}{1-x^k}=(1+x^k)(1+x^k+x^{2k}+\dots)=1+2x^k+2x^{2k}+\dots$$
Multiplying all these together and looking at terms contributing to the coefficient of $x^n$, we see that the term will be contributing something divisible by $4$ unless it comes from multiplying a bunch of $1$s together with $2x^{k\cdot d}$ for $k\mid n$. This means $a(n)\equiv 2d(n)\pmod 4$, where $d(n)$ is the number of divisors of $n$. Since $d(n)$ is odd iff $n$ is a square, we get the result.


