(A d2 solution)
Consider the expression (sin a + sin 2a + ... + sin na)
By adding pairwise the 1st and the last, the 2nd ad the penultimate we get ( n+1)/2 sums like ( sin ka + sin (n+1-k)a) which equals
.5(n+1)*2 sin((n+1)/2)*cos((2ka-n-1)a/2 #!
The (cos a + cos 2a + ... + cos na) equals, by the same token to
.5(n+1)*2 cos((n+1)/2)*cos((2ka-n-1)a/2 #2
Dividing #! by #2 we get tan [(n+1)a/2]
Rem : It is easy to reason out that both formulas are valid both for even and odd number of terms.
Edited on August 24, 2014, 1:31 pm