Finding the sum of the real parts squared of the roots of unity

I was solving a diophantine equation when I reached this point and I got stuck finding the value of
$$\sum_{k=1}^n \cos^2\left(\frac{360^{\circ}}n k\right).$$ I noticed that this sum resembles the sum of the real parts squared of the roots of unity.
After graphing the function and/or plugging in some values you can quickly realize that $$\sum_{k=1}^n \cos^2\left(\frac{360^{\circ}}n k\right) = \frac n2$$ for all natural numbers greater than $$2.$$

• How can we prove this?

$$\sum_{k=1}^n\cos^2(2\pi k/n)=\frac{1}{2}\sum_{k=1}^n(\cos(4\pi k/n)+1)=\frac{n}{2}$$ since $$\sum_{k=1}^n\cos(4\pi k/n)=\mathrm{Re}\sum_{k=1}^ne^{4\pi ki/n}=0$$.
• why is this true $\mathrm{Re}\sum_{k=1}^ne^{4\pi ki/n}=0$ – Ak2399 Oct 3 '20 at 6:37
• $\sum_{k=0}^{n-1}e^{4\pi ik/n}=1+\omega+\cdots+\omega^{n-1}=\frac{1-\omega^n}{1-\omega}=0$ since $\omega^n=e^{4\pi i n/n}=1$. – Chrystomath Oct 3 '20 at 6:39