Answer. f(x)=ax+b, where b is an arbitrary integer, and a is an arbitrary positive integer with ℧(a)=0.
A straightforward check shows that all the functions listed in the answer satisfy the problem condition. It remains to show the converse.
Assume that f is a function satisfying the problem condition. Notice that the function g(x)=f(x)−f(0) also satisfies this condition. Replacing f by g, we assume from now on that f(0)=0; then f(n)>0 for any positive integer n. Thus, we aim to prove that there exists a positive integer a with ℧(a)=0 such that f(n)=an for all n∈Z.
We start by introducing some notation. Set N=10100. We say that a prime p is large if p>N, and p is small otherwise; let S be the set of all small primes. Next, we say that a positive integer is large or small if all its prime factors are such (thus, the number 1 is the unique number which is both large and small). For a positive integer k, we denote the greatest large divisor of k and the greatest small divisor of k by L(k) and S(k), respectively; thus, k=L(k)S(k).
We split the proof into three steps.
Step 1. We prove that for every large k, we have k∣f(a)−f(b)⟺k∣a−b. In other words, L(f(a)−f(b))=L(a−b) for all integers a and b with a>b.
We use induction on k. The base case k=1 is trivial. For the induction step, assume that k0 is a large number, and that the statement holds for all large numbers k with k<k0.
Claim 1. For any integers x and y with 0<x−y<k0, the number k0 does not divide f(x)−f(y).
Proof. Assume, to the contrary, that k0∣f(x)−f(y). Let ℓ=L(x−y); then ℓ⩽x−y<k0. By the induction hypothesis, ℓ∣f(x)−f(y), and thus lcm(k0,ℓ)∣f(x)−f(y). Notice that lcm(k0,ℓ) is large, and lcm(k0,ℓ)⩾k0>ℓ. But then
℧(f(x)−f(y))⩾℧(lcm(k0,ℓ))>℧(ℓ)=℧(x−y)
which is impossible.
Now we complete the induction step. By Claim 1, for every integer a each of the sequences
f(a),f(a+1),…,f(a+k0−1) and f(a+1),f(a+2),…,f(a+k0)
forms a complete residue system modulo k0. This yields f(a)≡f(a+k0)(modk0). Thus, f(a)≡f(b)(modk0) whenever a≡b(modk0).
Finally, if a≡b(modk0) then there exists an integer b′ such that b′≡b(modk0) and ∣a−b′∣<k0. Then f(b)≡f(b′)≡f(a)(modk0). The induction step is proved.
Step 2. We prove that for some small integer a there exist infinitely many integers n such that f(n)=an. In other words, f is linear on some infinite set.
We start with the following general statement.
Claim 2. There exists a constant c such that f(t)<ct for every positive integer t>N.
Proof. Let d be the product of all small primes, and let α be a positive integer such that 2α>f(N). Then, for every p∈S the numbers f(0),f(1),…,f(N) are distinct modulo pα. Set P=dα and c=P+f(N).
Choose any integer t>N. Due to the choice of α, for every p∈S there exists at most one nonnegative integer i⩽N with pα∣f(t)−f(i). Since ∣S∣<N, we can choose a nonnegative integer j⩽N such that pα∤f(t)−f(j) for all p∈S. Therefore, S(f(t)−f(j))<P.
On the other hand, Step 1 shows that L(f(t)−f(j))=L(t−j)⩽t−j. Since 0⩽j⩽N, this yields
f(t)=f(j)+L(f(t)−f(j))⋅S(f(t)−f(j))<f(N)+(t−j)P⩽(P+f(N))t=ct
Now let T be the set of large primes. For every t∈T, Step 1 implies L(f(t))=t, so the ratio f(t)/t is an integer. Now Claim 2 leaves us with only finitely many choices for this ratio, which means that there exists an infinite subset T′⊆T and a positive integer a such that f(t)=at for all t∈T′, as required.
Since L(t)=L(f(t))=L(a)L(t) for all t∈T′, we get L(a)=1, so the number a is small.
Step 3. We show that f(x)=ax for all x∈Z.
Let Ri={x∈Z:x≡i(modN!)} denote the residue class of i modulo N!.
Claim 3. Assume that for some r, there are infinitely many n∈Rr such that f(n)=an. Then f(x)=ax for all x∈Rr+1.
Proof. Choose any x∈Rr+1. By our assumption, we can select n∈Rr such that f(n)=an and ∣n−x∣>∣f(x)−ax∣. Since n−x≡r−(r+1)=−1(modN!), the number ∣n−x∣ is large. Therefore, by Step 1 we have f(x)≡f(n)=an≡ax(modn−x), so n−x∣f(x)−ax. Due to the choice of n, this yields f(x)=ax.
To complete Step 3, notice that the set T′ found in Step 2 contains infinitely many elements of some residue class Ri. Applying Claim 3, we successively obtain that f(x)=ax for all x∈Ri+1,Ri+2,…,Ri+N!=Ri. This finishes the solution.