Calculate: $\sum_{k=0}^{n-2} 2^{k} \tan \left(\frac{\pi}{2^{n-k}}\right)$ Calculate the following sum for integers $n\ge2$:
$$\sum_{k=0}^{n-2} 2^{k} \tan \left(\frac{\pi}{2^{n-k}}\right)$$ 
I'm trying to obtain a closed form if that is possible.

We have this nice identity $$\tan(\theta) = \cot(\theta)-2 \cot(2 \theta)$$
Making use of this, and denoting $\displaystyle \sum_{k=0}^{m} 2^k \tan(2^k \theta)$ as $S$,  we get that \begin{align}S & = \tan(\theta) + 2 \tan(2 \theta) + 4 \tan(4 \theta) + \cdots + 2^m \tan(2^m \theta)\\
& = \cot(\theta) -2 \cot(2 \theta) +2 \cot(2\theta) - \cdots + 2^m \cot(2^m \theta) - 2^{m+1} \cot(2^{m+1} \theta)\\
& = \cot(\theta) - 2^{m+1} \cot(2^{m+1} \theta)
\end{align}
In your case, $\theta = \dfrac{\pi}{2^n}$ and $m= n-2$. Hence, we get the sum to be $$S = \cot \left(\dfrac{\pi}{2^n} \right) - 2^{n-1} \cot \left( 2^{n-1} \cdot \dfrac{\pi}{2^n}\right) = \cot \left(\dfrac{\pi}{2^n} \right) - 2^{n-1} \cot \left( \dfrac{\pi}2\right) = \cot \left(\dfrac{\pi}{2^n} \right)$$
Proof for $\tan(\theta) = \cot(\theta)-2 \cot(2 \theta)$
$$\cot(\theta) - \tan(\theta) = \dfrac{\cos(\theta)}{\sin(\theta)} - \dfrac{\sin(\theta)}{\cos(\theta)} = \dfrac{\cos^2(\theta) - \sin^2(\theta)}{\sin(\theta) \cos(\theta)}= 2\dfrac{\cos(2\theta)}{\sin(2 \theta)} = 2 \cot(2 \theta)$$
