Finding the smallest index $l$ with $x_l$ = $x_{2l}$ in a seqeunce 
The sequence $(x_i)_{\displaystyle i \geq 0}$  has the preperiod
  $2,3,5,7,11,13,17,19,23,29$ and the periodic part $31,37,41,43$. Find
  the smallest index $l \in \mathbb{N}$ with $x_l = x_{2l}$.

In other words, the sequence is
$$2,3,5,7,11,13,17,19,23,29,31,37,41,43,31,37,41,43,...$$
By inspection I found out that the answer is $l=12$. But I am not so much interested in the answer but rather if there more general way of finding the answer which does not involve writing out the sequence and comparing individual elements.

The sequence verifies $a_{10+k} = a_{10 + (k \; {\rm mod}\; 4)}$ for $k\geq 0$ (and there are no other relations). So look for $\ell=10+k$, $k\geq 0$ so that
$a_{10+k}=a_{20+2k}=a_{10+(10+2k)}$. And this  is equivalent to $k\geq 0$ and
 $$ k \equiv 10+2 k \ {\rm mod} \ 4 $$
or $k \equiv 2 \ {\rm mod} \ 4$.
