Let $f(x)$ be a rational function which is a ratio of two integral polynomials, and $n \in \mathbb Z$. Then the sequence of iterates $n, f(n), f(f(n)), f(f(f(n)), ...$ will be an infinite sequence of rational numbers, except in the rare cases where some iterate is a pole of $f$.


In the special case that $f(x) = \frac{a}{x^m}$ it happens that, when $n \ne 0$ is divisible by $a$ (also a nonzero integer), the iterates of $n$ under $f$ are integers infinitely often and non-integers infinitely often. 



> 
> Are there any other examples where $n, f(n), f(f(n)), f(f(f(n)), ...$ contains both infinitely many integers and infinitely many non-integers?
> 
> 
> 



Integrality of iterates of rational functions
As **Pasten** suggested in the comments, the key tool here is Siegel's theorem,
and this was already done by Silverman, see "Theorem A" in



> 
> Joseph H. Silverman:
>  Integer points, Diophantine approximation, and iteration of rational maps,
>  *Duke Math. J.* **71** (1993) #3, 793--829.
> 
> 
> 


**Proposition.** *Fix a rational function $f \in {\bf Q}(x)$,
and some $n\_0 \in {\bf Q} \cup \{\infty\}$;
for $i=1,2,3,\ldots$, define $n\_i$ inductively by $n\_i = f(n\_{i-1})$.
Then if $n\_i \in \bf Z$ for infinitely many $i$, then either*


*(i) $\{n\_i\}$ is periodic, or*


*(ii) $f$ has the form $f(x) = c + a/(x-c)^m$ for some $a,c \in \bf Q$
(with $a \neq 0$) and $m>1$, or*


*(iii) $f$ is a polynomial.*


In each case it is also possible to have $n\_i \notin \bf Z$
for infinitely many $i$. Note that case (ii) contains **Kimball**'s example,
and is in fact equivalent to it under conjugation by $x \mapsto x+c$.


The point is that if $\{n\_i\}$ is not periodic then for each $j=1,2,3,\ldots$
the $j$-th iterate $f^j$ satisfies $f^j(x) \in \bf Z$
for infinitely many distinct $x \in \bf Q$, whence $f^j$ has
at most two distinct poles By Siegel's theorem on integral points.
Silverman uses this to show that $f^2$ is polynomial, and thence that
$f$ is either polynomial or of the form exhibited in (ii) by citing
a result from



> 
> A. Beardon: *Iteration of Rational Functions* (GTM **132**),
>  New York: Springer 1991
> 
> 
> 


($\S$4.1), which he describes as "elementary" and "well-known",
and also proves as Proposition 1.1 of his paper (pages 798--799).


A simple example of a polynomial whose iterates can take both
integer and non-integer values is $f(x) = x + a$ for non-integral 
$a \in \bf Q$, say $f(x) = x+\frac12$. More complicated examples such as
$f(x) = 2x^2 + \frac12$ can be obtained as $f(x) = P(cx)/c$ for
suitable polynomials $P$ of degree $2$ or greater (here $P(x) = x^2+1$
and $c=2$). One can even construct examples such as $f(x) = x^2 + \frac{x}{2}$
for which it is probably true that the iterates of every integer include
both integers and non-integers but this is very hard to prove
(this example encodes the behavior of the parity of iterates of
$x \mapsto (x^2+x)/2$).


