The property of the solutions of Pell-Fermat equation Write
$$ 
(1+\sqrt{2})^n=a_n+b_n\sqrt{2}
$$
for $n,a_n,b_n$ are positive integers.
For each prime number $p$,
I would like to ask  if $p|b_n$ for some $n$？
Thanks.
 A: Yes - The $a_n$ and $b_n$ satisfy the recurrences $a_{n+1}=a_n+2b_n$ and $b_{n+1} = a_n+b_n$, for $n\in\mathbb{N}$. This can be used to extend the definition of the $a_n$ and $b_n$ to all $n$, including zero and negative. Now consider these sequences $\pmod{p}$. Since there are only $p^2$ possible (ordered) pairs of remainders $(a_n \pmod{p},b_n \pmod{p})$, the sequence of pairs must repeat in a loop of at most $p^2$. Since, with the extended definition, we have that $b_0 \equiv 0 \pmod{p}$, we will eventually have $b_k \equiv 0 \pmod{p}$ for some $k$ with $0 < k \leq p^2$, and then for infinitely many $b_n$.
A: As Old John has noted, $p$ will divide some $b_n$ for some $n \le p^2.$ This is just to note that it seems usually to happen sooner, namely at $n=p \pm 1$, or before in some cases. The primes $p=2,5$ are exceptional: $2|b_n$ when $2|n$ and $5|b_n$ when $3|n$. If we let $f(p)$ denote the least positive $n$ with $p|b_n$, the pattern seems to be that $p$ divides precisely the $b_k$ for which $f(p)|k.$ Some early values:
$$f(3)=4,\ f(7)=6,\ f(11)=12,\ f(13)=7,\ f(17)=8,\\ f(19)=20,\ f(23)=22,\ f(29)=5,\ f(31)=30.$$
It is (in all cases but $p=2,5$) so far the case that $f(p)$ is $p \pm 1$ or a divisor of one of them. It would be interesting if this could be proved, perhaps along the lines of the argument given in Old John's answer.
