We can write this sum S as Re(e^ix+e^2ix+...+e^nix), we now have a finite geometric series, which we know the formula for.Have, S = Re( e^ix(1-e^inx)/(1-e^ix)) - Now factoring numerator and denominator to look like complex formula for sine function we get,S = Re( e^ixe^inx/2(e^-inx/2-e^inx/2)/(e^ix/2(e^-ix/2-e^ix/2))) = Re(e^i(n/2+1/2)xsin(nx/2)/sin(x/2))Now since n is an integer and x is an element of the reals taking the real part gives,S = sin(nx/2)cos(((n+1)/2)x)/sin(x/2)