Finitely many upper and lower peaks prevent convergence (source code)

= Finitely many upper and lower peaks prevent convergence

Suppose both $(a_n)$ and $(-a_n)$ have only finitely many <peaks of a sequence>. Beyond some index $N$, every term has a strictly larger later term and a strictly smaller later term. Starting from $a_N$, construct one strictly increasing and one strictly decreasing <monotone subsequence>.

If the original <sequence> had <limit of a sequence> $L$, both selected <subsequences> would tend to $L$. The increasing one has a second term strictly above $a_N$, so $L>a_N$; the decreasing one similarly forces $L<a_N$. This contradiction proves nonconvergence. For example, $a_n=(-1)^nn$ has no <peaks of a sequence> in either sign and diverges.