Orbits
Orbits
CJ Quines
May 1, 2023
Warmup
(IMO 1987) Prove that there is no function f : N → N such that f (f (n)) = n + 1987 for all n.
(a) In the equation, substitute f (n) for n. In the equation, apply f to both sides. Show that this
means f (f (n)) ≡ n (mod 1987).
(b) Consider a directed graph with the vertices 0, 1, . . . , 1986. Draw an arrow n → f (n). What
does f (f (n)) ≡ n (mod 1987) mean?
(c) In this graph, every vertex is in a cycle. What are the possible cycle sizes in this graph?
Conclude there exists a such that a ≡ f (a) (mod 1987).
(d) Hence, f (a) = a + 1987k for some k ∈ Z. Hence f (f (a)) = f (a + 1987k) = f (a) + 1987k.
Then get a contradiction.
Definitions
Let S be a set. Given f : S → S:
• We can extend f to subsets of S by saying f (X) = {f (x) | x ∈ X}, and similarly for f n .
• The orbit of x, written orbf (x), is {x, f (x), f 2 (x), . . .}. When f is clear, we write orb(x).
• The period of x is the smallest n such that f n (x) = x. If it exists, we call x periodic.
• The functional graph of f is a directed graph with vertices in S, and arrows from x to f (x).
These aren’t quite standard, so define them when you use them. Facts with no proof necessary:
• The period of x, if it exists, equals the size of its orbit. We abuse notation and write orb(x)
for both the orbit and period of x.1
• In the functional graph, every vertex has outdegree 1. Conversely, a graph where each vertex
has outdegree 1 is a functional graph.
• In the functional graph, if S is finite, each connected component has exactly one directed
cycle. The rest of the component is a bunch of trees leading into the cycle. The converse is
also true. If S is infinite, then instead of a cycle, it can have a ray or a line, but it still has
exactly one of these three.
• In the functional graph, if f is injective, each vertex has indegree at most 1. Then connected
components are exactly cycles, rays, or lines.
The connected component fact is important, because the connected components partition S. This is
what we used for (c) in the warmup to conclude that there’s a cycle of size 1. It’s a way to frame
the problem that makes it easier to reason globally.
Examples
1. (Floyd 1957) Let S be a finite set, and f : S → S. Show that, for every x ∈ S, there exists a
positive integer n such that f n (x) = f 2n (x).
Sketch: Let a be the smallest non-negative integer such that f a (x) is periodic, and let
` = orb(f a (x)). Then f a+i (x) = f a+i+k` (x) for every non-negative i and k. Pick large k,
i = k` − a, and n = k`.
Remark: A similar argument shows there’s N such that f N (x) = f 2N (x) for all x ∈ S.
2. (Peru TST 2019) In each cell of a chessboard with 2 rows and 2019 columns a real number is
written so that:
• There are no two numbers written in the first row that are equal to each other.
• The numbers written in the second row coincide with (in some another order) the numbers
written in the first row.
• The two numbers written in each column are different and they add up to a rational
number.
Determine the maximum quantity of irrational numbers that can be in the chessboard.
Sketch: Let S be the set of numbers in the first row, and f : S → S take a number to the one
below it. A cycle with an irrational number has all irrational numbers and even length. Cycles
partition S, so some cycle has odd length, and third condition means no cycles of length 1.
3. (Iran 1992) Let X be a finite set, and f : X → X. Suppose there exists a prime p such that
f p (x) = x for all x ∈ X. Let Y = {x ∈ X | f (x) 6= x}. Prove that p | |Y |.
Sketch: If f p (x) = x, then orb(x) | p, and thus is either 1 or p. The functional graph’s
connected components are all cycles of length 1 or p, but these partition X.
4. (ELMO SL 2018) Let f : R → R be bijective. Does there always exist infinitely many g : R → R
such that f (g(x)) = g(f (x)) for all x ∈ R?
Sketch: Yes. Consider the functional graph. If we have a line, we can let g = f n on the chain
and let g fix everything else. Otherwise it’s infinitely many disjoint cycles. Pick any cycle; we
can let g = f on this cycle and let g fix everything else.
3 CJ Quines
Problems
1. (Russia TST 2020) Let f (x) = x2 + ax − 1 for some real a. Sasha found 50 real roots of the
equation f 47 (x) = x. Prove that this equation has at least 96 real roots. Hint: 23
2. (Macedonia TST 2021) Let S = {1, 2, 3, . . . 2021} and f : S → S be a function such that
f n (n) = n for each n ∈ S. Find all possible values for f (2021). Hint: 9
3. (Japan 2022) Find all functions f : N → N, such that for any positive integers m and n,
Hints: 3 14
n2
f f (n) (n) =
f (f (n))
for all positive integers n. Find all possible values of f (1000). Hints: 3 30
5. (ISL 2017) Let S be a finite set, and let f : S → S. Suppose that f ◦ g ◦ f 6= g ◦ f ◦ g for every
g : S → S with g 6= f . Show that f (f (S)) = f (S). Hints: 25 11
6. (Taiwan TST 2021) Let g(x) = (|x| + |x − 1| − 1)/2. Find all f : N → N such that
7. (ISL 2009) Let P (x) be a non-constant polynomial with integer coefficients. Prove that there
is no function T : Z → Z such that the number of integers x with T n (x) = x is equal to P (n)
for every positive integer n. Hints: 24 16
8. (Korea Winter Camp 2017) Find all functions f : N → N satisfying the following conditions:
• For every n ∈ N, f n (n) = n.
• For every m, n ∈ N, |f (mn) − f (m)f (n)| < 2017. Hints: 27 3
Harder problems
9. (APMO 2013) Let a, b be positive integers, and let A, B be finite disjoint sets, such that if
i ∈ A ∪ B, then i + a ∈ A or i − b ∈ B. Show that a|A| = b|B|. Hints: 1 13
10. (ELMO 2021) Let n > 1 be an integer and let a1 , a2 , . . . , an be integers such that n | ai − i for
all integers 1 ≤ i ≤ n. Prove there exists an infinite sequence b1 , b2 , . . . such that
• bk ∈ {a1 , a2 , . . . , an } for all positive integers k, and
∞
X bk
• is an integer. Hints: 10 20
nk
k=1
12. (USA TST 2020) Find all integers n ≥ 2 for which there exists an integer m and a polynomial
P (x) with integer coefficients satisfying the following three conditions:
• m > 1 and gcd(m, n) = 1;
• the numbers P (0), P 2 (0), . . ., P m−1 (0) are not divisible by n; and
• P m (0) is divisible by n. Hints: 17 8
13. (ISL 2012) Let f : N → N. Suppose that for every n ∈ N there exists a k ∈ N such that
f 2k (n) = n + k, and let kn be the smallest such k. Prove k1 , k2 , . . . is unbounded. Hints: 22 19 6
14. (ISL 2010) The rows and columns of a 2n × 2n table are numbered from 0 to 2n − 1. The
cells of the table have been coloured with the following property being satisfied: for each
0 ≤ i, j ≤ 2n − 1, the j-th cell in the i-th row and the (i + j)-th cell in the j-th row have the
same colour. (The indices of the cells in a row are considered modulo 2n .) Prove that the
maximal possible number of colours is 2n . Hints: 26 2 28
15. (RMM 2019) Find all pairs of integers (c, d), both greater than 1, such that for any prime
p > c(2c + 1), and any monic integer polynomial Q with degree d, there exists S ⊆ Z such that
|S| 2c − 1
• ≤ , and
p 2c + 1
[
• s, Q(s), Q2 (s)), Q3 (s), . . . ≡ {0, 1, . . . , p − 1} (mod p). Hints: 7 29 5
s∈S
Hints
1. Show that the graph with edges i → j if j = i + a ∈ A or j = i − b ∈ B is a functional graph.
2. What’s the size of the orbit of (1, 1)? Try small n and guess the pattern.
3. Start by showing injectivity.
4. Take a maximum matching in the underlying undirected graph.
5. Of the vertices not in isolated cycles, at least d1 are in the range of Q. This is a good enough
bound.
6. Each connected component corresponds to a fixed value of f 2x (a) − x, so orbf 2 (a) contains
all but finitely many positive integers.
7. Answer is c ≥ d. If c < d, take Q(x) = xd and some p ≡ 1 (mod d) prime.
8. For the function P mod pe , prove that if q | orb(0), then q ≤ p.
9. The answer is everything divisible by 43.
10. Think about how . You’re looking for periodic b.
P b
= nb + n1
P b
nk nk
5 CJ Quines
Sketches
1. If f 47 (x) = x then orb(x) is 1 or 47. There’s two points with orbit 1, so there’s at least 48
points with orbit 47. In particular, the 48 points have to come from at least two different
orbits of size 47, meaning there’s actually at least 94 points with orbit 47.
2. We have orb(2021) | 43 · 47, casework on orb(2021). If 1, it’s 2021. If 2021, it’s impossible as
f (1) = 1. If 47, it’s also impossible: if n ∈ orb(2021), then 47 | n, but there’s only 43 such
n, which is less than 47. Similarly if 43, everything in orbit is divisible by 43. We can set
f (2021) to any of these.
3. Answer is f (n) = n + 1, check it works. Show injectivity by P (a, n) and P (b, n). By P (n, n)
we get f (n) > n. Functional graph is disjoint rays. By P (a, b) and P (b, a), we get a and b are
in the same orbit, thus the ray has all of N.
4. Answer is all evens, give construction. Show injectivity by P (a) and P (b). Let m = min orb(n).
Then P (m) means f f (m) (m)f 2 (m) = m2 . Factors in LHS are both in orb(n), so by minimality
they’re both m. Thus f 2 (m) = m, and orb(n) has size 2, and thus f 2 (n) = n for all n.
Equation is now f f (n) (n) = n. Argue by parity that f (1000) can’t be odd.
5. By a similar argument to Floyd, there’s some n such that f n+2 = f 2n+1 . (If it’s eventually
periodic, it has period N . Pick large n such that n ≡ −1 (mod N ).) Set g = f n . Then
f ◦ g ◦ f = g ◦ f ◦ g so g = f = f n , and thus f is a bijection on f (S).
6 CJ Quines
6. Answer is f (x) = x or x + 1 pointwise; i.e. we can pick x or x + 1 for different xs. Suppose
g(f (x) − x) > 0, then orb(x) exists, and orb(x) | g(f (x) − x), hence f (x) − x ≡ 0 or 1
(mod orb(x)). In particular, the difference between consecutive terms in the orbit is 0 or 1
(mod orb(x)), but at the end of the orbit we go back to x, so they’re all 0. If g(f (x) − x) = 0,
then f (x) = x or x + 1 anyway.
7. Take the functional graph. We canPignore everything not in a cycle. Let cd be the number
of cycles of length d, then P (n) = d|n d · cd . For prime p we get P (p) ≡ c1 (mod p), hence
P (0) ≡ c1 (mod p) for all primes p, and thus P (0) = c1 . Also, P (pq) ≡ c1 + qcq (mod p).
Hence qcq ≡ 0 (mod p) for any other prime q, hence cq = 0. Hence P (q) = c1 for all primes q,
and P is constant, contradiction.
8. Answer is f (n) = n, check it works. The hard part is showing second condition gives
multiplicativity, which we prove later; for now assume f (mn) = f (m)f (n). Show injectivity
by P (a) and P (b). For prime p, we get orb(p) | p. If orb(p) = p, then everything in its orbit
must also be divisible by p, so f p−1 (p) = kp for some p. Then p = f p (p) = f (f p−1 (p)) =
f (kp) = kf (p) by multiplicativity. But f (p) is also in the orbit, and also divisible by p, hence
k = 1 and f (p) = p.
Now we show multiplicativity. If f (mn) 6= f (m)f (n), then
f (k) ≤ |f (mn) − f (m)f (n)| f (k)
= |f (mn)f (k) − f (m)f (n)f (k)|
≤ |f (mn)f (k) − f (mnk)| + |f (mnk) − f (m)f (nk)| + |f (m)f (nk) − f (m)f (n)f (k)|
= |f (mn)f (k) − f (mnk)| + |f (mnk) − f (m)f (nk)| + f (m) |f (nk) − f (n)f (k)|
< 2017 + 2017 + f (m) · 2017.
where the third line follows from the triangle inequality. This means f is bounded above, but
f is surjective by first condition, so this is absurd.
9. Consider graph with vertices A ∪ B and i → j if j = i + a ∈ A or j = i − b ∈ B. We’re given
each vertex has outdegree at least 1. But a vertex can have indegree at most 1, so outdegrees
are exactly 1. This is a functional graph, and consists of disjoint cycles. If the orbit of i has x
edges that add a and y edges that subtract b, then its orbit has x elements in A and y in B.
But i = i + ax − by so x/y = b/a; summing over orbits gives the answer.
10. Take indices mod n and let f : Z → Z be f (i) = (a−i + i)/n. Then f is upper bounded, so we
must have a cycle starting at some x. Then if k = orb(x) − 1, we get
k−1
!
a−f k (x) + f k (x) a−f k (x) a−f k−1 (x) + f k−1 (x) X a−f k−i (x) x
x= = + 2
= ··· = i+1
+ k,
n n n n n
i=0
12. The answer is all n such that there are primes q < p where p | n and q - n. Suppose n satisfies
this. Set m = q and interpolate to find P (0), P 2 (0), . . . , P q−1 (0), P q (0) ≡ 1, 2, . . . , q − 1, 0
(mod pνp (n) ) and P (0) ≡ 0 for all other primes dividing n. This is the construction.
Let p be a prime, and write o(e) = orbP mod pe (0). We claim that if q is a prime such that
q | o(e), then q ≤ p. If we can show this we’re done, as then m can’t satisfy gcd(m, n) = 1.
Prove through induction on e. For e = 1 the orbit can only take on p values anyway. For
inductive case, as P o(e) (0) ≡ 0 (mod pe ), we also have P o(e) (0) ≡ 0 (mod pe−1 ), and hence
o(e − 1) | o(e). But one of o(e − 1), 2o(e − 1), . . . , (p − 1)o(e − 1) is 0 by pigeonhole, so o(e)
must equal one of them. Either q divides the first factor which is less than p, or divides the
second factor, which works by inductive hypothesis.
13. First, f has no cycles. If it did, we can set x = max orbf (n), then by condition f 2kx (x) = x+kx
is also in orbf (n), contradicting maximality. Pick some a. Define g : orbf 2 (a) → orbf 2 (a) as
2i+2kf 2i (a) 2kf 2i (a)
g(f 2i (a)) = f (a) = f (f 2i (a)) = f 2i (a) + kf 2i (a) ,
the third equality from the problem statement. Note that g is injective by minimality of
kf 2i (a) . Further, g has no cycles because f has no cycles. Thus g’s functional graph is disjoint
rays. Suppose the ks are upper bounded by M . Then g(x) = x + kwhatever ≤ x + M , so each
ray has density ≥ M 1
, and there’s at most M rays.
Let orbg (f 2i (a)) be one of the rays. If f 2x (a) ∈ orbg (f 2i (a)), expanding the definition shows
for some constant m, taken over the maximum of all the rays in g. (This is why we need a
finite number of rays.) Thus the xth term in orbf 2 (a) is at most x + m, and orbf 2 (a) contains
all but finitely many positive integers. Finally, orbf (1) is the disjoint union of orbf 2 (1) and
orbf 2 (f (1)). But these can’t be disjoint for size reasons.
14. Equivalent to showing that, if f : Z22n → Z22n is f (j, i) = (i + j, j) mod 2n , its functional
graph has 2n connected components. We proceed by induction. When both coordinates
are even we reduce to the 2n−1 case, so there’s 2n−1 components for those. We claim if at
least one coordinate is odd, the orbits all have size 3 · 2n−1 ; this would finish the problem.
Note f k (a, b) = (aFk + bFk−1 , aFk−1 + bFk ), so we need to calculate when (a, b) ≡ f k (a, b)
(mod 2n ), and this is now a number theory problem. The key claims are ν2 (F6m ) = ν2 (m) + 3
and ν2 (F6m−1 − 1) = ν2 (F6m+1 − 1) = ν2 (m) + 2, and I won’t bother proving these here lol.
15. Answer is c ≥ d. If c < d, take Q(x) = xd , let p ≡ 1 (mod d) be prime. Then Q’s range has
only 1 + p−1
d elements, so S must include d (p − 1) elements, which fails the size condition.
d−1
For c ≥ d, take the functional graph of Q. Let ck be the number of k-cycles without trees
pointing into them. BuildPS by taking one vertex from each of these cycles, plus every vertex
of indegree 0. Of the p − k · ck vertices not in the cycles, at least d1 of them are in the range
of Q. (Q has degree d, so vertices have maximum indegree d.) Thus we can bound the size of
S by
d−1 X (k − 1)d − k
X 1 X 1 d−1
ck + 1 − p− k · ck = · p + · c1 − · ck ≤ · p + 1,
d d d d d
16. Show injectivity by P (x, n) and P (y, n) for large x, y. Functional graph is a finite number
of disjoint rays by second condition. We claim each orbit is either an arithmetic sequence
or has density 0. Set g(a) = f a (x) − x. Then g(0) = 0, and from P (f b (x), a − b), we get
a − b | g(a) − g(b).
Suppose dn = g(n + 1) − g(n) was upper bounded by N . From a − b | da − db , setting a − b > N
for enough differences we can force dn to be constant, and then g is an arithmetic sequence,
and we’re done. Now suppose it was unbounded. Again from a − b | da − db , setting a − b > db
shows it eventually only contains numbers at least db , and so the density is at most d1b , and
this is true for any db , so it’s density 0.
The orbits have to cover N, and they’re all infinite, so they can’t have density 0. Thus each
orbit is an arithmetic sequence and we’re done.