Evaluate $\prod_{k=1}^{n-1} \cos \frac{k \pi}{n}$ where $\text{gcd}(n,k)=1$ and $n$ is odd Prove that $\prod\limits_{1 \le k \le n-1,\gcd(n,k)=1} \cos \frac{k \pi}{n}=\frac{(-1)^{\varphi(n)}}{2^{\varphi (n)}}$ where $n$ is an odd number.
I used the same method as here but how can we evaluate $\prod\limits_{1 \le k \le n-1,\gcd(n,k)=1} (e^{\frac{2ik \pi }{n}}+1)$?
 A: If we consider the $n$-th cyclotomic polynomial $\Phi_n(z)$ we have
$$\Phi_n(z) = \prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!\left(z-e^{\frac{2\pi i k}{n}}\right) \tag{A}$$
and the degree of $\Phi_n(z)$ is clearly $\varphi(n)$. It follows that:
$$ (-1)^{\varphi(n)}\Phi_n(-1) = \prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!\left(1+e^{\frac{2\pi i k}{n}}\right)=2^{\varphi(n)}\prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!e^{\frac{\pi i k}{n}}\prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!\cos\frac{\pi k}{n} $$
and rearranging:
$$ \prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!\cos\frac{\pi k}{n} = \frac{(-1)^{\varphi(n)}}{2^{\varphi(n)}}\Phi_n(-1)\exp\left[-\frac{\pi i}{n}\!\!\!\!\sum_{\substack{1\leq k\leq n \\ \gcd(k,n)=1}}\!\!\!k\right]\tag{B} $$
Assuming $n>2$ and $1\leq k\leq n$, $\gcd(k,n)=1$ implies $\gcd(n-k,n)=1$, hence $(B)$ simplifies into:
$$ \prod_{\substack{1\leq k\leq n\\ \gcd(k,n)=1}}\!\!\!\cos\frac{\pi k}{n} = \frac{(-1)^{\frac{3}{2}\varphi(n)}}{2^{\varphi(n)}}\Phi_n(-1)\tag{C} $$
so it is enough to compute $\Phi_n(-1)$ in terms of $n$. By Moebius inversion formula
$ \Phi_n(x)=\prod_{d\mid n}(x^d-1)^{\mu\left(\frac{n}{d}\right)} $, hence if $n$ is odd we have $\Phi_n(-1)=1$. 

If $n$ is even we may write $n=2^{\nu_2(n)}\cdot m$ and
$$\Phi_n(-1)=\lim_{x\to -1}\prod_{\substack{d\mid n\\ d\text{ even}}}(x^d-1)^{\mu\left(\frac{n}{d}\right)} $$
so $\Phi_n(-1)$ equals $2$ if $n$ is a power of $2$ and $1$ if $n$ is not a power of $2$ but $4\parallel n$. It only remains to study $\Phi_{4k+2}(-1)$ to solve the given problem in full generality, but that is beyond the scope of the original question. Anyway, $\Phi_{4k+2}(-1)$ equals $p$ if $2k+1$ is a number of the form $p^\eta$ and $1$ otherwise.
