Let $f$ be a function such that for every $\varepsilon
> 0,\ n^{\log n} \leq f(n) \leq n^{\varepsilon n}$ holds if $n$ is
sufficiently large. Suppose that $\log f(n) / \log n$ is
nondecreasing. Using sequences of finite alternating groups, for
every such $f$ we construct a $4$-generator group $\Gamma$ such
that $s_n(\Gamma)$, the number of subgroups of index at most $n$
in $\Gamma$, grows like $f(n)$.
¶
This essentially completes the investigation of the ``spectrum''
of possible subgroup growth types and settles several questions
posed by Lubotzky, Mann, and Segal.
¶
As a by-product we obtain continuously many nonisomorphic
$4$-generator residually finite groups with isomorphic profinite
completions.
¶
Our construction also sheds some light on a problem of
Grothendieck [Gr]; we obtain an abundance of pairs of finitely
generated residually finite groups $\Gamma_0 \lessthan \Gamma$, such that
the natural map $\widehat \imath : \widehat\Gamma_0 \to
\widehat\Gamma$ between profinite completions is an isomorphism,
but $\Gamma_0 \not \cong \Gamma$.