8. The sequence $\left\{a_{n}\right\}$ is defined as follows: $a_{1}=1$, and for $n \geqslant 2$, $a_{n}=\left\{\begin{array}{ll}a_{\frac{n}{2}}+1, & n \text { is even; } \\ \frac{1}{a_{n-1}}, & n \text { is odd. }\end{array}\right.$ If $a_{n}=\frac{20}{11}$, then the positive integer $n=$ $\qquad$
8. 198 .

From the problem, we know that when $n$ is even, $a_{n}>1$; when $n(n>1)$ is odd, $a_{n}=\frac{1}{a_{n-1}}1$, so, $n$ is even. Thus, $a_{\frac{n}{2}}=\frac{20}{11}-1=\frac{9}{11}1, \frac{n}{2}-1$ is even;
$a_{\frac{n-2}{4}}=\frac{11}{9}-1=\frac{2}{9}1, \frac{n-6}{4}$ is even;
$a_{\frac{n-6}{8}}=\frac{9}{2}-1=\frac{7}{2}>1, \frac{n-6}{8}$ is even;
$a_{\frac{n-6}{16}}=\frac{7}{2}-1=\frac{5}{2}>1, \frac{n-6}{16}$ is even;
$a_{\frac{n-6}{32}}=\frac{5}{2}-1=\frac{3}{2}>1, \frac{n-6}{32}$ is even;
$a_{\frac{n-6}{4}}=\frac{3}{2}-1=\frac{1}{2}1, \frac{n-70}{64}$ is even;
$a_{\frac{n-70}{128}}=2-1=1$.
Therefore, $\frac{n-70}{128}=1 \Rightarrow n=198$.