6. If the sequence $\left\{a_{n}\right\}$ satisfies
$$
a_{n+1}=\left\{\begin{array}{ll}
2 a_{n}, & 0 \leqslant a_{n}<\frac{1}{2} ; \\
2 a_{n}-1, & \frac{1}{2} \leqslant a_{n}<1 .
\end{array}\right.
$$

If $a_{1}=\frac{6}{7}$, then $a_{23}=$
A. $\frac{6}{7}$
B. $\frac{5}{7}$
C. $\frac{3}{7}$
D. 0
6. B Because $a_{1}=\frac{6}{7}, a_{2}=2 \times \frac{6}{7}-1=\frac{5}{7}, a_{3}=2 \times \frac{5}{7}-1=\frac{3}{7}, a_{4}=2 \times a_{3}=\frac{6}{7}, a_{5}=\frac{5}{7}, a_{6}=\frac{3}{7}, \ldots$ this indicates that the sequence $\left\{a_{n}\right\}$ has a period of 3, and since $23=3 \times 7+2$, we have $a_{23}=a_{2}=\frac{5}{7}$, hence the answer is $\mathrm{B}$.