Compute Hann window without cos function
i think this generates a sinusoid:
$$ y[n] = 2 \cos(\omega_0) y[n-1] - y[n-2] $$
if you initialize
$$ y[-2] = \cos(2 \omega_0) $$
$$ y[-1] = \cos(\omega_0) $$
then the result is
$$ y[n] = \cos(\omega_0 n) \qquad n \ge 0$$
the period of this cosine function is $N=\frac{2\pi}{\omega_0}$ and you want $N-1$ to be the non-zero width of the window.
finally you construct your window with
$$ w[n] = \tfrac{1}{2} (1 - y[n]) \qquad  0 \le n \le N$$