TITLE: A condition for a sequence defined by a recurrence relationship to all be integers
QUESTION [11 upvotes]: I am interested in a specific sequence $\{a_n \}$ defined by a simple recurrence relationship: $$a_n = \frac {a_{n-1} ^2 +c} {b} $$ where $b,c\in \mathbb{Z}$. I want to find all $b,c$ such that there exists some integer $a_1$ such that $\{a_n\} $ are all integers.
I think that this would be a well-known problem, but I have trouble finding it. Even if this is not well-known, I cannot find a way to solve this question.
For example, if $b=3$ and $c=1$, it is fairly trivial that there exists no such $a_1 $. if $b=3$ and $c=2$, we can let $a_1 = 1 $ to make all $\{a_n \}$ be integers. However, I cannot easily work this out even in a single case, such as $b=3, c=17$. Furthermore, how can I find all $(b,c)$ such that there exists some $a_1$ such that $a_n \in \mathbb Z$ for all $n\in \mathbb{N}$?
*I posted this on SEMath, but I did not get any answers nor references. https://math.stackexchange.com/questions/1470398/a-condition-for-a-sequence-defined-by-a-recurrence-relationship-to-all-be-intege

REPLY [3 votes]: $\let\eps\varepsilon$This is not an answer, but just an attempt to summarize flaming (at least inspired by myself, sorry) appeared in the comments to the answer by @Joe Silverman. I would kindly ask Joe's permission to delete those comments, if all of them are correctly reflected here. It is not that convenient to walk through all of them... 
On the other hand, I may easily delete this if it disturbes someone.
So, following Joe's approach, we fix an odd $p\mid b$ (assuming $b$ is odd and square-free, and $b\nmid c$) and search for $p$-adic integers $a$ such that for $a_1=a$ the whole sequence consists of $p$-adic integers. Surely, we assume that $-c\equiv \mu^2\pmod{p}$ for some integer $\mu$. Then it is easy to see that if $(a_n)$ is as desired, then $a_n\equiv\pm \mu\pmod p$ for all $n$.
We claim that for every sequence $\eps=(\eps_1,\dots,\eps_n)$ with $\eps_i\in\{-1,1\}$, there exists a unique residue $r_{\eps}$ such that for $a_1\equiv r\pmod{p^n}$ all $a_1,\dots,a_n$ are ($p$-adic) integers with $a_i\equiv\eps_i\mu\pmod p$. The base $n=1$ is clear. For the step, apply the inductive hypothesis to $a_2,\dots,a_{n+1}$; we find that $a_2\equiv r_{\bar\eps}\pmod{p^n}$, where $\bar\eps=(\eps_2,\dots,\eps_{n+1})$. Now, from $a_1^2=ba_2-c$ we obtain two possible residues for $a_1\pmod {p^{n+1}}$ corresponding to $a_1\equiv \pm \mu\pmod p$, as required. The claim is proved.
Thus, for every infinite sequence $\eps_1,\eps_2,\dots$ there exists a sequence $r_{\eps_1},r_{\eps_1,\eps_2},\dots$ converging to some $p$-adic integer $R_{\eps_1,\eps_2,\dots}$ (obviously, these residues agree).
Now again comes the hard part. We need to find out whether one of these $p$-adic numbers is actually an integer. 
An easy case is when the sequence $\eps_1,\eps_2,\dots$ is periodic. Then, due to the uniqueness, the sequence starting from $R_\eps$ is periodic as well.  This sequence may indeed be constant, e.g. 
$$
  a_n=\frac{a_{n-1}^2+b-1}b, \quad a_1=1.
$$ 
It may also be cyclic with longer period, e.g., 
$$
  a_n=\frac{a_{n-1}^2-(1+b+b^2)}b, \quad a_1=1, \quad a_2=-(b+1).
$$ 
I am almost sure that arbitrarily long periods may appear; but for every fixed choice for $b$ and $c$ they can be found easily: since $\frac{x^2+c}b>x$ for all sufficiently large $x$, it suffices to check only the sequences consistinc of small numbers.
The case when $\eps$ is an aperiodic sequence seems to be, eh, much harder (and, perhaps, not approachable by such elementary methods). But still, some heuristics: all the $R_\eps$ form some Cantor set in $p$-adic numbers, and it has zero measure, so it is quite improbable that one of these numbers is integer. Nevertheless, it is not clear why it cannot happen (if it really cannot).
Notice also that in any case, some of the $R_\eps$ are algebraic (two of them satisfies $x^2-bx+c=0$, and some generate longer cycles), while some are transcendent (since there are continuum many of them).