Let AA and BB be positive integers. Consider a sequence of positive integers (xn)n1(x_{n})_{n\geq 1} such that

xn+1=Agcd(xn,xn1)+Bfor every n2.x_{n+1} = A \cdot \gcd(x_{n}, x_{n-1}) + B \quad \text{for every } n \geq 2.

Prove that the sequence attains only finitely many different values.

Remark. We denote by gcd(a,b)\gcd(a, b) the greatest common divisor of positive integers aa and bb.