In this paper, we first determine the number of signed permutations with exactly k inversions, which is denoted by \(i_B(n,k)\) and called Mahonian numbers of type B. Then we provide a recurrence relation for the Mahonian numbers \(i_B(n,k)\) . In addition, we give a recursive formula for the summation of the inversion numbers of all permutations in the hyperoctahedral group \(B_n\) , denoted by \(\mathcal {B}_n\) . Furthermore, we concretely compute the summation \(\mathcal {B}_n\) with the help of an inversion statistic and the backward permutation concepts on \(B_n\) . Moreover, we compute the weight on the group \(D_n\) of even-signed permutations of \(inv_D\) statistic. Finally, we deduce for any classical Weyl group W with the reflection set T that \(\frac{|W||T|}{2}=\sum _{w \in W}l(w),\) where l denotes the length function on W.