Sequence of coprime integers

elementary-number-theoryprime numbers

I am working on this problem:

Let $f(x)=x^2-2x+2$. Define a sequence
$$
\begin{align*}
a_0&=3\\
a_1&=f(a_0)=5\\
a_2&=f(a_1)=17\\
&\vdots\\
a_n&=f(a_{n-1}).
\end{align*}
$$

Prove that, for all $n$, if $p$ is a prime dividing $a_n$, then $p$ does not divide any $a_m$, where $m>n$.

What I've done so far: I know that if $x$ and $y$ are integers then $x-y$ divides $f(x)-f(y)$, since $f$ is a polynomial with integer coefficients. Therefore, if $p$ divides both $a_n$ and $a_m$, then $p$ divides $a_m-a_n$, so $p$ divides $f(a_m)-f(a_n)=a_{m+1}-a_{n+1}$, and so on. However, I am stuck trying to reach a contradiction. Any assistance would be appreciated, thanks!

Best Answer

If $p$ divides $a_n$, then

$$ a_{n+1} = f(a_n) = a_n^2 - 2a_n + 2 \equiv 2 \pmod p $$

What happens next?

Related Question