Sequence $a_k=1-\frac{\lambda^2}{4a_{k-1}},\ k=2,3,\ldots,n$.

Consider the sequence $a_1, a_2,\ldots,a_n$ with $a_1=1$ and defined recursively by

$$a_k=1-\frac{\lambda^2}{4a_{k-1}},\ k=2,3,\ldots,n.$$

Find $\lambda>1$ such that $a_n=0$.

The answer is $\lambda=\dfrac1{\cos\frac{\pi}{n+1}}$.

Solutions Collecting From Web of "Sequence $a_k=1-\frac{\lambda^2}{4a_{k-1}},\ k=2,3,\ldots,n$."

The sequence $(a_k)$ is defined by iterating the homography $h:a\mapsto1-\lambda^2/(4a)$ hence the two fixed points of $h$ yield a dilation $h$ is conjugate to. Those fixed points are $\alpha_\pm=\frac12(1\pm\mu)$ where $\mu^2+\lambda^2=1$, and
$$
\frac{h(a)-\alpha_+}{h(a)-\alpha_-}=\beta\cdot\frac{a-\alpha_+}{a-\alpha_-},
$$
for some $\beta$ which can be computed noting that $h(0)=+\infty$ hence $\beta=\alpha_-/\alpha_+$. In particular, if $a_1=1$ and $a_n=h^{n-1}(a_1)=0$, one gets
$$
\frac{\alpha_+}{\alpha_-}=\beta^{n-1}\cdot\frac{1-\alpha_+}{1-\alpha_-}=\left(\frac{\alpha_-}{\alpha_+}\right)^{n-1}\cdot\frac{\alpha_-}{\alpha_+},
$$
that is,
$$
\left(\frac{\alpha_+}{\alpha_-}\right)^{n+1}=1.
$$
Furthermore, $a_k\ne0$ for every $k\lt n$ (otherwise $a_{k+1}$ is undefined) hence the same computation yields
$$
\left(\frac{\alpha_+}{\alpha_-}\right)^{k+1}\ne1,\qquad k\lt n.
$$
All this means that $\alpha_+=\omega\cdot\alpha_-$, where $\omega$ is a primitive $(n+1)$-th root of $1$, that is, $\omega^{n+1}=1$ and $\omega^{k}=1$ for every $1\leqslant k\leqslant n$. Hence $\mu=\frac{\omega-1}{\omega+1}$ and $\lambda^2=1-\mu^2=\frac{4\omega}{(1+\omega)^2}$. Writing $\omega$ as $\omega=\mathrm e^{2\mathrm i\theta}$, one gets
$$
\lambda^2=\frac4{(\mathrm e^{\mathrm i\theta}+\mathrm e^{-\mathrm i\theta})^2}=\frac1{\cos^2(\theta)},
$$
where $\theta$ can be any angle $\alpha$ such that $(n+1)\theta=0\pmod{\pi}$ and $k\theta\ne0\pmod{\pi}$ for every $1\leqslant k\leqslant n$.

Finally, the answer is NOT was is written in the question but
$$
\lambda=\frac{1}{\cos\left(\frac{k\pi}{n+1}\right)}\quad\text{for some}\ 1\leqslant k\leqslant n\ \text{such that}\ \mathrm{gcd}(k,n+1)=1.
$$