Let $p$ be a prime number and $G$ be a group. I have some troubles to understand the proof of ${\rm ord}(G)=p^n \Rightarrow Z(G) \neq \{e\}$. The proof is given as follow:
Observe the Group $G$ acting on itself by conjugation, then we have:
$$x \in Z(G) \iff Z_G(\{x\})=G \iff (G:Z_G(\{x\}))=1$$
Until here it is okay, but now it goes on with: So $$x \neq Z(G) \Rightarrow p\, \mid \frac{{\rm ord}(G)}{{\rm ord}(Z_G(\{x\}))}.$$
Why we get this inclusion? The last is because of the lagrange theorem but why we take $x \neq Z(G)$?
Many thanks for some help.
By the class formula, $|G|=|Z(G)|+\sum_i [G:Z_G(x_i)]$. If $x\in G\setminus Z(G)$, its centralizer $Z_G(x)$ is a subgroup of $G$, so it has order $p^k$. So $[G:Z_G(x_i)]=p^{n-k}$, and thus if $|Z(G)|=1, |G|\equiv 1\pmod{p}$, a contradiction. Hence $Z(G)$ is a nontrivial p-subgroup of $G$.