The center of the dihedral group [closed]

How to prove that the center of the dihedral group $D_{2n}$ is $\{1,r^{n}\}$ and the center of $D_{2n-1}$ is $\{1\}$?

I don't know how to prove it in this general case.


Let us conjugate a general element of the form $r^as$ by another element $r^bs$. $$(r^bs)r^as(sr^{-b})=r^bsr^ar^{-b}=r^{2b-a}s$$ Since in general this depends on $b$, an element of this form cannot be in the center. Now let's conjugate $r^a$ by $r^bs$: $$(r^bs)r^a(sr^{-b})=r^{-a}$$ For completeness we note $$r^br^ar^{-b}=r^a$$ Thus the only way an element $r^a$ can be in the center is if $r^a=r^{-a}$, meaning the rotation commutes with reflections. This means $$r^{2a}=1$$ $a=0$ will always work; for a dihedral group of order $2(2n)$, we can also take $a=n$. For a dihedral group of order $2(2n-1)$ there is no $a$ such that $r^a$ has order $2$, hence the center is trivial.