Let $A, B \in \mathbb{N}$. Consider a sequence $x_1, x_2, \ldots$ such that for all $n\geq 2$, $$x_{n+1}=A \cdot \gcd(x_n, x_{n-1})+B. $$Show that the sequence attains only finitely many distinct values.
Problem
Source: MEMO 2023 T8
Tags: number theory
25.08.2023 12:46
Given the sequence x_n, define the two auxiliary sequences (for $n>1$) $d_n=(x_n,x_{n-1})$ and $e_n=(d_n,B)$. For $n>1$, we note that $e_n|d_n$, which implies $e_n|Ad_n+B=x_{n+1}$, which implies $e_n|(x_{n+1},x_n)=d_{n+1}$; therefore $e_n|e_{n+1}$, since it divides both $d_{n+1}$ and $B$. So, $e_2|e_3|...|B$, implying that the sequence eventually stabilizes [here we used that $B\neq 0$ because $0\not in \mathbb{N}$] on some number $e$, for $n\geq N$. Letting $x_n=ex'_n$ and $B=eB'$, we have (for $n\geq N$) that $ex'_{n+1}=Ae(x'_n,x'_{n-1})+eB'\implies x'_{n+1}=A(x'_n,x'_{n-1})+B'$. This new sequence is bounded if and only if the original sequence is bounded, and furthermore defining as before the sequences $d'_n,e'_n$, we must have $e'_n=1$ (for $n\geq N$)[otherwise the original sequence wouldn't have satisfied $e_n=e\forall n\geq N$], so wlog our original sequence satisfied $e_n=1\forall n\geq 2$. This also implies that $D:=(A,B)=1$, because otherwise, $D$ would divide all terms starting from $x_3$, which further implies that $D|e_n=(x_n,x_{n-1},B)$ (for $n\geq 4$) which is a contradiction. Now, we have $$d_{n+1}=(x_{n+1},x_n)=(Ad_n+B,Ad_{n-1}+B)=$$$$=(Ad_n+B,A(d_n-d_{n-1})|(Ad_n+B,A)(Ad_n+B,d_n-d_{n-1})=$$$$=(A,B)(Ad_n+B,d_n-d_{n-1})=(Ad_n+B,d_n-d_{n-1})|d_n-d_{n-1}$$. So $d_{n+1}\leq |d_n-d_{n-1}|\leq \max\{d_n, d_{n-1}\}$. This clearly implies that $d_n$ is bounded, meaning that $x_{n+1}=Ad_n+B$ is also bounded, as wanted.