Problem: Let $a_1$, $a_2$, \dots\ be an infinite sequence of positive integers,
and $N$ a positive integer.
Suppose that for all integers $n \ge N$, the expression
\[ \frac{a_1}{a_2} + \frac{a_2}{a_3} + \dots
  + \frac{a_{n-1}}{a_n} + \frac{a_n}{a_1} \]
is an integer.
Prove that $(a_n)$ is eventually constant.

Solution: The condition implies that the difference
\[ S(n) = \frac{a_{n+1} - a_n}{a_1} + \frac{a_n}{a_{n+1}} \]
is an integer for all $n > N$.
We proceed by $p$-adic valuation only henceforth;
fix a prime $p$.
Then analyzing the $\nu_p$, we immediately get that for $n > N$:
\begin{itemize}
\ii If $\nu_p(a_n) < \nu_p(a_{n+1})$, then $\nu_p(a_{n+1}) = \nu_p(a_1)$.
\ii If $\nu_p(a_n) = \nu_p(a_{n+1})$, no conclusion.
\ii If $\nu_p(a_n) > \nu_p(a_{n+1})$,
then $\nu_p(a_{n+1}) \ge \nu_p(a_1)$.
\end{itemize}
In other words:
\begin{claim*}
Let $p$ be a prime.  Consider the sequence
$\nu_p(a_{N+1})$, $\nu_p(a_{N+2})$, \dots.
Then either:
\begin{itemize}
  \ii We have $\nu_p(a_{N+1}) \ge \nu_p(a_{N+2}) \ge \dots$
  and so on, i.e.\ the sequence is weakly decreasing immediately; or
  \ii For some index $K > N$ we have
  $\nu_p(a_K) < \nu_p(a_{K+1}) = \nu_p(a_{K+2}) = \dots = \nu_p(a_1)$,
  i.e.\ the sequence ``jumps'' to $\nu_p(a_1)$
  at some point and then stays there forever after.
  Note this requires $\nu_p(a_1) > 0$.
\end{itemize}
\end{claim*}

A cartoon of the situation is drawn below.
\begin{center}
  \begin{asy}
    label("$\nu_p(a_1)$", (0,3), dir(180), deepcyan);
    draw( (0,3)--(11,3), blue+dotted );
    draw( (0,9)--(0,-1)--(12,-1), black, Arrows );
    dot( (1,6), red );
    dot( (2,5), red );
    dot( (3,5), red );
    dot( (4,5), red );
    dot( (5,4), red );
    dot( (6,4), red );
    dot( (7,4), red );
    dot( (8,3), red );
    dot( (1,9), darkred );
    dot( (2,7), darkred );
    dot( (3,6), darkred );
    dot( (4,6), darkred );
    dot( (5,6), darkred );
    dot( (6,6), darkred );
    dot( (7,6), darkred );
    dot( (8,6), darkred );
    dot( (9,6), darkred );
    draw( (1,6)--(2,5)--(4,5)--(5,4)--(7,4)--(8,3), red );
    draw( (1,9)--(2,7)--(3,6)--(4,6)--(9,6), darkred );
    dot( (1,1), brown );
    dot( (2,1), brown );
    dot( (3,1), brown );
    dot( (4,1), brown );
    dot( (5,1), brown );
    dot( (6,3), brown );
    dot( (6,3), brown );
    draw( (1,1)--(5,1)--(6,3), brown );
    dot( (1,0), orange );
    dot( (2,0), orange );
    dot( (3,0), orange );
    dot( (4,0), orange );
    dot( (5,0), orange );
    dot( (6,0), orange );
    dot( (7,0), orange );
    dot( (8,0), orange );
    dot( (9,0), orange );
    draw( (1,0)--(9,0), orange );
    draw( (1,-0.8)--(1,-1.2) );
    draw("$n > N$", (1,-1.2), dir(-90) );
  \end{asy}
\end{center}

As only finitely many primes $p$ divide $a_1$,
after some time $\nu_p(a_n)$ is fixed for all such $p \mid a_1$.
Afterwards, the sequence satisfies $a_{n+1} \mid a_n$ for each $n$,
and thus must be eventually constant.

\begin{remark*}
  This solution is almost completely $p$-adic,
  in the sense that I think a similar result
  holds if one replaces $a_n \in \ZZ$
  by $a_n \in \ZZ_p$ for any particular prime $p$.
  In other words, the primes almost do not talk to each other.

  There is one caveat: if $x_n$ is an integer sequence
  such that $\nu_p(x_n)$ is eventually constant for each prime
  then $x_n$ may not be constant.
  For example, take $x_n$ to be the $n$th prime!
  That's why in the first claim (applied to co-finitely many of the primes),
  we need the stronger non-decreasing condition,
  rather than just eventually constant.
\end{remark*}

\begin{remark*}
  An alternative approach is to show that, when the fractions $a_n / a_1$
  is written in simplest form for $n = N+1, N+2, \dots$,
  the numerator and denominator are both weakly decreasing.
  Hence it must eventually be constant; in which case it equals $\frac11$.
\end{remark*}