Note that $n$ is the sum over prime divisors $p$ of $|G|$ of the minimal number of generators of the distinct Sylow $p$-subgroups of $G.$ The minimal number of generators of a finite $p$-group is well defined by properties of the Frattini subgroup. Use of the Frattini subgroup helps to prove the other inequality: take a prime $p$ which divides $d_1$. Then a Sylow $p$-subgroup of $G$ can't be generated by fewer than $k$ elements, so $G$ itself certainly can't be generated by fewer than $k$ elements, as each Sylow $p$-subgroup of $G$ is a homomorphic image of $G.$