If k∈Z is even then for f:Z→Z, f(x)=x+2k we get:
f(f(n))=(n+2k)+2k=n+k
For k even it is therefore possible to find function f:Z→Z with the property that f(f(n))=n+k for all n∈Z. It can therefore be assumed that k is odd, in particular k is non-zero.
For all n∈Z we get following:
f(n)−n=(f(n)+k)−(n+k)=f(f(f(n)))−(n+k)=f(n+k)−(n+k)
Using induction it can be shown that f(n+m⋅k)−(n+m⋅k)=f(n)−n for all m∈N. If p,q∈Z, and p≡q(mod ∣k∣) then there is a natural number m such that p=q+m⋅k or q=p+m⋅k. In either case f(m)−m=f(n)−n,
equivalently f(m)−f(n)=m−n. As m≡n(mod∣k∣), f(m)−f(n)=m−n≡0(mod∣k∣), that is f(m)≡f(n)(mod∣k∣).
If m∈Z, f(f(m−k))=(m−k)+k=m so m is in the image of f. As m is arbitrary this means that f is surjective. If m,n∈Z and f(m)=f(n), we get:
m=(m+k)−k=f(f(m))−k=f(f(n))−k=(n+k)−k=n,
that is f is injective. As f is both injective and surjective it is bijective. Assume m,n∈Z and f(m)≡f(n)(mod∣k∣). Then
m≡m+k≡f(f(m))≡f(f(n))≡n+k≡n(mod∣k∣)
Let h:{0,1,…,∣k∣−1}→{0,1,…,∣k∣−1}:x↦(f(x)(mod∣k∣)). From last equation we infer that h is injective. As
h(h(n))=f(f(n)(mod∣k∣))(mod∣k∣)=f(f(n))(mod∣k∣)=(n+k)(mod∣k∣)=n
for all n∈{0,1,…,∣k∣−1}. That is h is an involution and we see that h is bijective. Assume h has a fixed point n0. As n0=h(n0)=f(n0)(mod∣k∣) we conclude that f(n0)−n0=m⋅∣k∣ where m∈Z.
It has already been shown that f(n0+m⋅∣k∣)−(n0+m⋅∣k∣)=f(n0)−n0=m⋅∣k∣ so:
k=f(f(n0))−n0=(f(f(n0))−f(n0))+(f(n0)−n0)=(f(n0+m⋅∣k∣)−(n0+m⋅∣k∣))+m⋅∣k∣=m⋅∣k∣+m⋅∣k∣=2⋅m∣k∣
This implies ∣k∣=2∣m∣∣k∣. As k=0 we get 2∣m∣=1 which is impossible as 1 is odd. The assumption that n0 is a fixed point of h must therefore be false.
Given n∈Z h(n)=n and h(h(n))=n so the sets {n,h(n)} and {h(n),h(h(n))} are equal and each contains two distinct elements. Now
{0,1,…,∣k∣−1}=⋃{{n,h(n)}∣n∈{0,1,…,∣k∣−1}}.
As each subset of A:={{n,h(n)}∣n∈{0,1,…,∣k∣−1}} contains two elements it follows that the union ⋃A={0,1,…,∣k∣−1} contains an even number of elements. The cardinality of {0,1,…,∣k∣−1} is ∣k∣ which is odd and we get a contradiction. This shows that if k is odd there is no function f:Z→Z such that f(f(n))=n+k for all n∈Z.
Function f:Z→Z satisfying f(f(n))=n+k for all n∈Z can therefore be found if and only if k is even. □