Show that $$1+z+z^2 + \cdots + z^{n-1} = 1 + i \cot \left(\frac{\pi}{2n}\right)$$ where $z = \cos\left(\frac{\pi}{n}\right) + i \sin\left(\frac{\pi}{n}\right)$ where $n \in \mathbb{Z^+}$
This question has confused me slightly and has left me rather stuck.
My attempt so far has been:
Note that $z = e^{i\frac{\pi}{n}}$ and that $$1+z+z^2+\cdots + z^{n-1} = \frac{1 - z^n}{1-z} \\ = \frac{1- e^{i\pi}}{1-e^{i\frac{\pi}{n}}} = \frac{2}{1-e^{i\frac{\pi}{n}}}$$
but I don't see a way to go from here...
Any help is appreciated.
$$1+z+z^2+\cdots + z^{n-1}$$
$$ = \frac{1 - z^n}{1-z} $$
$$ = \frac{1- e^{i\pi}}{1-z} $$
$$= \frac{2}{1-z }$$
$$=\frac{2(1-\bar z)}{(1-z)(1-\bar z) }$$
$$=\frac{2(1-cos(\pi/n)+i\sin(\pi/n))}{2-2\cos (\pi/n) }$$
$$=1+i\frac {\sin(\pi/n)}{1-\cos(\pi/n)}=1+i\cot(\pi/{2n})$$
In the last step half angle identities were used.