Summing $1+\cos(\theta)+\cos(2\theta) +\cdots + \cos(n\theta)$
$$\frac{z^{n+1}-1}{z-1}=\frac{(z^{n+1}-1)\overline{(z-1)}}{|z-1|^2}\tag{$\ast$}$$
Denominator is real, so you need to separate numerator into real and imaginary parts.
$$(z^{n+1}-1)=(\cos((n+1)\theta)-1)+i\sin((n+1)\theta)\tag1$$$$\overline{(z-1)}=(\cos\theta-1)-i\sin\theta\tag2$$
Multiply (1) and (2) and extract real part.
The real part of the expression in $(\ast)$ is
$$\frac{(\cos((n+1)\theta)-1)(\cos\theta-1)+\sin((n+1)\theta)\sin\theta}{(\cos\theta-1)^2+\sin^2\theta}$$
The solution you saw with $\theta/2$ in bottom most likely simplified the denom as $2(1-\cos\theta)$ and used the identity $\cos(x)=\cos^2(x/2)-\sin^2(x/2)=1-2\sin^2(x/2)=2\cos^2(x/2)-1$
The numerator might also be simplified by expanding out and using trig identities which express $\cos x\cos y$ and $\sin x\sin y$ as sums of $\sin$ and $\cos$