TITLE: Number of subgroups of a given index of a free group
QUESTION [9 upvotes]: Given $n,d\in \mathbb{Z}^+$, how many subgroups of index $d$ does the free group of
rank $n$ have?
In case $n=1$ the question is trivial, and in case $n=2, d=2$ there are 3 such subgroups.
I think I have got a algorithm to solve case $d=2$ for arbitrary $n$.
But the general case seems very difficult. For example in case $n=2$ and $d$ a
prime number, I don't know how to proceed.
That's my question. Any suggestions will be appreciated.
Thanks

REPLY [15 votes]: This calculation was performed by Marshall Hall Jr. Let $N(d,n)$ be the number of subgroups of index $d$ in the free group of rank $n$.  Then
$N(d,n)=d(d!)^{n-1}-\sum_{i=1}^{d-1}((d-i)!)^{n-1}N(i,n)$.
One can prove this inductively by analysing permutation groups as in abx's answer, or alternatively by thinking about covering spaces of graphs---see the answers to this question on MSE for a few more details.