Problem

Source: Rio de Janeiro Mathematical Olympiad 2018, Level 4, #2

Tags: number theory, combinatorics



Let $(a_n)$ be a sequence of integers, with $a_1 = 1$ and for evert integer $n \ge 1$, $a_{2n} = a_n + 1$ and $a_{2n+1} = 10a_n$. How many times $111$ appears on this sequence?