I was studying the product of $n$th roots of unity, and the proof in the book went like this: $$1\cdot a\cdot a^2\cdot\cdots\cdot a^{n-1} \\=a^{0+1+2+3...+n-1} \\=a^{n(n-1)/2} \\=(\cos\frac{2\pi}n+i\sin\frac{2\pi}n)^{n(n-1)/2} \\=(\cos2\pi+i\sin2\pi)^{(n-1)/2} \\=(\cos\pi+i\sin\pi)^{n-1} \\=(-1)^{n-1} \\=\begin{cases}-1 &\text{if n is even;} \\1 &\text{if n is odd.}\end{cases}$$
But instead of doing that, if we simplified directly from $(\cos2\pi+i\sin2\pi)^{(n-1)/2},$ we'd get $$1^{(n-1)/2}=1.$$
So, where exactly was I wrong? I think the problem basically boils down to $$(-1)^x=1^{x/2}=1.$$ Obviously, this is wrong, but I can't spot where it is wrong. Also, why is it wrong?
Note that $n(n-1)/2$ is an integer. After all, it is a sum of integers.
I think the book makes a blunder by factoring $n(n-1)/2$ into an integer factor $n$ and another factor $(n-1)/2$ that might not be an integer. By doing this, it reaches a step where it must evaluate $1^{(n-1)/2}.$ This is not necessarily $1$ as you claim. But it also is not necessarily $-1$ when $n$ is even as the book claims. As several other answers have pointed out, when dealing with complex numbers we have to treat raising a number to a fractional power as a multivalued function, and in the case of $n$ even we simply cannot say whether $1^{(n-1)/2}$ is $1$ or $-1.$
What the book's argument does, in fact, is use the fallacious "identity" $z^{ab} = (z^a)^b$ for complex $z$ and arbitrary rational $a$ and $b.$ The equality sign before $(\cos2\pi+i\sin2\pi)^{(n-1)/2}$ is invalid.
If instead we recall that $n(n-1)/2$ is an integer, we can immediately multiply the argument of $\cos\frac{2\pi}n+i\sin\frac{2\pi}n$ by this integer with no ambiguity and no weird multivalued outputs. Quite simply,
\begin{align} \left(\cos\frac{2\pi}n+i\sin\frac{2\pi}n\right)^{n(n-1)/2} &= \cos\left(\frac{n(n-1)}2\cdot\frac{2\pi}n\right) + i\sin\left(\frac{n(n-1)}2\cdot\frac{2\pi}n\right) \\ &= \cos\left((n-1)\pi\right) + i\sin\left((n-1)\pi\right) \\ &= \begin{cases} -1 & \text{$n$ even,} \\ \phantom{-}1 & \text{$n$ odd.} \end{cases} \end{align}