I am trying to solve the following exercise about the dihedral group and its center:
If $g\in Z(D_{2n})\Leftrightarrow ga=ag, bg=gb$, where $a,b$ are generators of $D_{2n}$.
We have defined the dihedral group of order $2n$ as $D_{2n}=\left \{ a^{i}b^{j} \mid 0\leq i \leq n, j=0,1 \right \}$, the group of all finite products of the generators $a$ and $b$, where $a= \bigl(\begin{smallmatrix} 1 & 2 & 3 & \cdots & n-1 & n \\ \end{smallmatrix}\bigr)$ and $ b = \bigl(\begin{smallmatrix} 1 & 2 & 3 & \cdots & n-1 & n \\ 1 & n & n-1 & \cdots & 3 & 2 \end{smallmatrix}\bigr)$
For the first part ( $\Rightarrow $) i have considered an element $g$ of the center $Z(D_{2n})$, $g$ is also in $D_{2n}$, so it can be written as a finite product of powers of $a$ and $b$. Let's say $g=a^{k}b^{l}$ for $0 \leq k \leq n$ and $j=0$ or $j=1$. Then i can write $ga = a^{k}b^{l}a=a^{k+1}b^{l}$ and $ag=aa^{k}b^{l}=a^{k+1}b^{l}$. So $ga=ag$. The same for $gb=bg$.
Is this correct? How to start with the other part of the proof? I would appreciate any help and hints. Thank you in advance.