
Clear[partitions];
Clear[coeff];

coeff[n_Integer] := coeff[n] = 
   Module[ {a},

     a = Sqrt[1+24*n];

     Which[ 
       OddQ[(a+1)/6], -1,
       OddQ[(a-1)/6], -1,
       EvenQ[(a+1)/6], 1,
       EvenQ[(a-1)/6], 1,
       True, 0
     ]
   ];

coeff[0] = 0;


partitions[n_Integer] := partitions[n] = 
   Module[{r}, -Sum[partitions[r] * coeff[n-r], {r, 0, n-1}]];

partitions[0] = 1; 
partitions[1] = 1;
