Let $G$ be a (countable) residually finite group whose profinite completion is topologically finitely generated. Must $G$ be finitely generated?

1$\begingroup$ Wouldn't $\hat{\mathbb{Z}}$ be a counterexample? Or am I missing something? $\endgroup$ – Donu Arapura May 10 '15 at 16:58

$\begingroup$ @DonuArapura my fault. Edited. $\endgroup$ – Pablo May 10 '15 at 17:01

1$\begingroup$ Isn't $\mathbb{Z}_{(p)}$ still a counterexample? $\endgroup$ – Johannes Hahn May 10 '15 at 17:39

1$\begingroup$ @DonuArapura: yes it works (that subgroups of finite index in $\hat{\mathbf{Z}}$ can be checked by hand without any fancy theorem. By NikolovSegal (and Serre in the pro$p$case), any infinite topologically finitely generated profinite group also works. Of course it provides no countable example, but very simple countable examples have been pointed out as well. $\endgroup$ – YCor May 10 '15 at 20:55
$\begingroup$
$\endgroup$
No. Take $G=\oplus_{p} C_p$, where the sum is over all primes $p$ and $C_p$ is the cyclic groups of order $p$. Then $G$ is clearly locally finite and infinite and therefore not finitely generated. However, it is easy to see that the profinite completion of $G$ is $\Pi_p C_p$ which is a cyclic profinite group.