Pensieve header: Number of inversions and quantum factorials.

NOI[l_List] := Count[Subsets[l,{2}], Except[_?OrderedQ]]

NOI[{1,3,2}]

NOI /@ Permutations[Range[4]]

f[n_]:=Total[(q^(NOI/@Permutations[Range[n]]))]

f[4]

qfac[n_] := Expand[Product[Sum[(q^j),{j,0,k-1}],{k,n}]]

qfac[4]

f[9] // Timing

qfac[9] // Timing

f[10] // Timing

qfac[10] // Timing