Problem

Source: 8th European Mathematical Cup, Junior Category, Q4

Tags: number theory, relatively prime



Let $u$ be a positive rational number and $m$ be a positive integer. Define a sequence $q_1,q_2,q_3,\dotsc$ such that $q_1=u$ and for $n\geqslant 2$: $$\text{if }q_{n-1}=\frac{a}{b}\text{ for some relatively prime positive integers }a\text{ and }b, \text{ then }q_n=\frac{a+mb}{b+1}.$$Determine all positive integers $m$ such that the sequence $q_1,q_2,q_3,\dotsc$ is eventually periodic for any positive rational number $u$. Remark: A sequence $x_1,x_2,x_3,\dotsc $ is eventually periodic if there are positive integers $c$ and $t$ such that $x_n=x_{n+t}$ for all $n\geqslant c$. Proposed by Petar Nizié-Nikolac