2 Improved formatting

It's worth noting this special case: if $G$ is isomorphic to $(\mathbb{Z}/p)^r$ then it can be regarded as a vector space of dimension $r$ over the field $\mathbb{Z}/p$, and the subgroups are just the subspaces. The number of linearly independent lists of length $n$ is

$(p^r-1)(p^r-p)\dotsb(p^r-p^{n-1})$

(choose a nonzero vector $v_1$, then a vector $v_2$ not in the one-dimensional space spanned by $v_1$, then $v_2$ not in the 2-dimensional space spanned by $v_1$ and $v_2$, and so on). For any subspace $V$ of dimension $n$, the number of bases is

$(p^n-1)(p^n-p)\dotsb(p^n-p^{n-1})$

by the same argument. It follows that the number $N_n$ of subspaces of dimension $n$ is

$N_n = \frac{(p^r-1)\dotsb(p^r-p^{n-1})}{(p^n-1)\dotsb(p^n-p^{n-1})} = \frac{(p^r-1)(p^{r-1}-1)\dotsb(p-1)}{(p^n-1)(p^{n-1}-1)\dotsb(p-1)}$

1

It's worth noting this special case: if $G$ is isomorphic to $(\mathbb{Z}/p)^r$ then it can be regarded as a vector space of dimension $r$ over the field $\mathbb{Z}/p$, and the subgroups are just the subspaces. The number of linearly independent lists of length $n$ is $(p^r-1)(p^r-p)\dotsb(p^r-p^{n-1})$ (choose a nonzero vector $v_1$, then a vector $v_2$ not in the one-dimensional space spanned by $v_1$, then $v_2$ not in the 2-dimensional space spanned by $v_1$ and $v_2$, and so on). For any subspace $V$ of dimension $n$, the number of bases is $(p^n-1)(p^n-p)\dotsb(p^n-p^{n-1})$ by the same argument. It follows that the number $N_n$ of subspaces of dimension $n$ is

$N_n = \frac{(p^r-1)\dotsb(p^r-p^{n-1})}{(p^n-1)\dotsb(p^n-p^{n-1})} = \frac{(p^r-1)(p^{r-1}-1)\dotsb(p-1)}{(p^n-1)(p^{n-1}-1)\dotsb(p-1)}$