revised NrParts function to compute p(Q) and p(Q,N) -KL

Tested against Sage, bug-free.