Parity of number of partitions of a number into distinct parts

integer-partitionsnumber theoryprogramming

suppose for an integer n the number of partitions of n into distinct integers is f(n) then I want to determine the values of n for which f(n) is odd
for example for n=5, the number of such partitions is 3 which is odd

I wrote a program to find out for how many value of n from 1 to 6000 is the value of f(n) odd, that comes out to only 126.

But I need to find all the values of n for which f(n) is odd for n<1e10, is there any closed form solution which will help me calculate all these value of n upto 1e10 for which f(n) is odd

Best Answer

The generating function for paritions into distinct parts is $$F(q)=\sum_{n=0}^\infty f(n)q^n=(1+q)(1+q^2)(1+q^3)\cdots=\prod_{m=1}^\infty(1+q^m).$$ Compare $$G(q)=\sum_{n=0}^\infty g(n)q^n=(1-q)(1-q^2)(1-q^3)\cdots=\prod_{m=1}^\infty(1-q^m).$$ Then $f(n)$ and $g(n)$ have the same parity: $f(n)\equiv g(n)\pmod2$. But $$G(q)=1+\sum_{k=1}^\infty(-1)^k(q^{k(3k-1)/2}+q^{k(3k+1)/2})=\sum_{k=-\infty}^ \infty(-1)^k q^{k(3k-1)/2}$$ (Euler's pentagonal number formula). So $f(n)$ is odd iff $n$ has the form $\frac12 k(3k-1)$ for some $k\in\Bbb Z$.