Maths Olympiad Prep

Library / /1 of 2

Algebra Difficulty 8.3 Shortlist Prove it India

Find all f:NNf: \mathbb{N} \to \mathbb{N} such that f(x)+yf(x) + y and f(y)+xf(y) + x have the same number of 1's in their binary representation for any x,yNx, y \in \mathbb{N}.

Solutions — 2

Solution 1

We claim that all such functions are of the form f(n)=n+cf(n) = n + c for some natural number cc. The verification is trivial; now consider some function ff satisfying the given condition. For nNn \in \mathbb{N}, let d(n)d(n) denote the number of 1's in the binary representation of nn. Let P(x,y)P(x, y) denote the statement that f(x)+yf(x) + y and f(y)+xf(y) + x have the same number of 1's in their binary representation.

Claim 1 For any y,nNy, n \in \mathbb{N} with 2n>f(y)2^n > f(y), f(2nf(y))+yf(2^n - f(y)) + y is a power of two.

Proof. P(2nf(y),y)P(2^n - f(y), y) gives us that 2n2^n and f(2nf(y))+yf(2^n - f(y)) + y have the same number of 1's, and the former has exactly one 1, so f(2nf(y))+yf(2^n - f(y)) + y has exactly one 1, from which the claim follows. \square

Claim 2 f(y+2k)f(y)f(y + 2^k) - f(y) is a power of two for any k0k \ge 0 and y2ky \ge 2^k.

Proof. Choose an nn such that n>1000+log2(10+f(y+2k)f(y))n > 1000 + \log_2(10 + |f(y + 2^k) - f(y)|). By Claim 1, f(2nf(y))=2ty>0f(2^n - f(y)) = 2^t - y > 0 for some tt with tk+1t \ge k + 1. Therefore P(2nf(y),y+2k)P(2^n - f(y), y + 2^k) gives
d(2nf(y)+f(y+2k))=d(2t+2k)=2 d(2^n - f(y) + f(y + 2^k)) = d(2^t + 2^k) = 2
since tk+1t \ge k + 1. If f(y)=f(y+2k)f(y) = f(y + 2^k), then LHS is d(2n)=1d(2^n) = 1, contradiction! If f(y)>f(y+2k)f(y) > f(y + 2^k), and f(y)f(y+2k)f(y) - f(y + 2^k) has m<log2(10+f(y+2k)f(y))m < \log_2(10 + |f(y + 2^k) - f(y)|) digits, then
d(2nf(y)+f(y+2k))nm1999>2 d(2^n - f(y) + f(y + 2^k)) \ge n - m - 1 \ge 999 > 2
since 2nf(y)+f(y+2k)2^n - f(y) + f(y + 2^k) starts with at least nm1n-m-1 ones, contradiction! Therefore f(y+2k)>f(y)f(y+2^k) > f(y), and since nn is bigger than the number of digits in f(y+2k)f(y)f(y + 2^k) - f(y), there is no carry-over, so
2=d(2nf(y)+f(y+2k))=1+d(f(y+2k)f(y)) 2 = d(2^n - f(y) + f(y + 2^k)) = 1 + d(f(y + 2^k) - f(y))
which gives us f(y+2k)f(y)f(y + 2^k) - f(y) is a power of 2, as required \square

Claim 2 gives us f(y+1)f(y)=2t(y)f(y+1) - f(y) = 2^{t(y)} for some t(y)t(y), for all yy. But for y2y \ge 2, f(y+2)f(y)f(y+2) - f(y) is also a power of two     2t(y)+2t(y+1)\implies 2^{t(y)} + 2^{t(y+1)} is a power of two, which is only possible if t(y)=t(y+1)t(y) = t(y+1) for all y2y \ge 2. Therefore f(y+1)f(y)f(y+1) - f(y) is a constant power of two for all y2y \ge 2, say 2k2^k. This gives us f(y)=2ky+cf(y) = 2^k y + c for some constant cc, for all y2y \ge 2. Putting this in Claim 1, we get
2k+n(22k1)y(2k1)c 2^{k+n} - (2^{2k} - 1)y - (2^k - 1)c
is a power of two for any y2y \ge 2 and any sufficiently large nn. This is only possible if, for all y2y \ge 2,
(22k1)y+(2k1)c=0 (2^{2k} - 1)y + (2^k - 1)c = 0
    (2k1)((2k+1)y+c)=0 \iff (2^k - 1)((2^k + 1)y + c) = 0
which can only hold for all y2y \ge 2 if 2k=12^k = 1, i.e., f(y)=y+cf(y) = y + c for all y2y \ge 2. But Claim 1 for y=1y = 1 and large nn gives
2nf(1)+1+c 2^n - f(1) + 1 + c
is a power of two for all sufficiently large nn, which is only possible if f(1)=1+cf(1) = 1 + c. Therefore f(x)=x+cf(x) = x + c for all xNx \in \mathbb{N}.

Solution 2

We claim that all such functions are of the form f(n)=n+cf(n) = n + c for some natural number cc. The verification is trivial; now consider some function ff satisfying the given condition. For nNn \in \mathbb{N}, let d(n)d(n) denote the number of 1's in the binary representation of nn.

Claim 1 Given any NNN \in \mathbb{N}, there exists mNm \in \mathbb{N} so that f(m)>Nf(m) > N.

Proof. Suppose that there is NNN \in \mathbb{N} so that f(m)<Nf(m) < N for all mNm \in \mathbb{N}. Let kNk \in \mathbb{N} be such that 2k>N+12^k > N + 1. Note that d(f(22k2k)+1)=d(22k2k+f(1))d(f(2^{2k} - 2^k) + 1) = d(2^{2k} - 2^k + f(1)). The right hand side is at least k+1k + 1 which the left hand side is at most kk, a contradiction. This proves our claim. \square

Claim 2 The function ff is injective.

Proof. Suppose there are a,b,cNa, b, c \in \mathbb{N} so that f(a)=f(b)=cf(a) = f(b) = c. Then, for any natural number kk with 2k>c2^k > c, we have 1=d(f(a)+2kc)=d(a+f(2kc))1 = d(f(a) + 2^k - c) = d(a + f(2^k - c)). This implies f(2kc)=2raf(2^k - c) = 2^r - a for some rNr \in \mathbb{N}. Similarly f(2kc)=2sbf(2^k - c) = 2^s - b for some sNs \in \mathbb{N}. This implies that ab=2r2sa - b = 2^r - 2^s. Therefore exist unique rr and ss such that f(2kc)=2ra=2sbf(2^k - c) = 2^r - a = 2^s - b for all natural numbers kk with 2k>c2^k > c. Let nn be a natural number such that f(n)c>2cf(n) - c > 2c, which exists by the previous lemma. Let kNk \in \mathbb{N} be such that 2kf(n)c<2k+12^k \le f(n) - c < 2^{k+1} (note that this ensures 2k>c2^k > c). Then d(2k+f(n)c)=d(f(n)c)d(2^k + f(n) - c) = d(f(n) - c), but d(2k+1+f(n)c)=d(f(n)c)+1d(2^{k+1} + f(n) - c) = d(f(n) - c) + 1. This is a contradiction because
d(2kc+f(n))=d(f(2kc)+n)=d(f(2k+1c)+n)=d(2k+1c+f(n)). d(2^k - c + f(n)) = d(f(2^k - c) + n) = d(f(2^{k+1} - c) + n) = d(2^{k+1} - c + f(n)).
Thus ff must be injective. \square

Now let a,ba, b be natural numbers so that f(a)=bf(a) = b. As in the proof of the previous lemma, for any natural number kk with 2k>b2^k > b we have f(2kb)=2raf(2^k - b) = 2^r - a for some rNr \in \mathbb{N}.

Claim 3 There exists a natural number KK such that for all k>Kk > K, we have f(2kb)=2kaf(2^k - b) = 2^k - a.

Proof. Suppose the contrary. Let k,rk, r be distinct natural numbers so that f(2kb)=2raf(2^k - b) = 2^r - a. Further choose distinct l,sl, s different from kk and rr, so that f(2lb)=2saf(2^l - b) = 2^s - a. Then
d(f(2kb)+2lb)=d(2r+2l(a+b))=f(2kb+f(2lb))=d(2s+2k(a+b)).(1) d(f(2^k - b) + 2^l - b) = d(2^r + 2^l - (a + b)) = f(2^k - b + f(2^l - b)) = d(2^s + 2^k - (a + b)). \quad (1)
Since ff is injective, we may further assume 2min(k,l,r,s)>a+b2^{\min(k,l,r,s)} > a + b. Note that if mNm \in \mathbb{N} is such that 2m>a+b2^m > a + b, then d(2m+1(a+b))=d(2m(a+b))+1d(2^{m+1} - (a+b)) = d(2^m - (a+b)) + 1. Thus equation (1) cannot hold, proving our claim. \square

Let kk be a natural number such that f(2kb)=2kaf(2^k - b) = 2^k - a and 2k>4f(a1)b2^k > 4|f(a - 1) - b|. Note that
k=d(2k1)=d(f(2kb)+a1)=d(2kb+f(a1)). k = d(2^k - 1) = d(f(2^k - b) + a - 1) = d(2^k - b + f(a - 1)).
If b>f(a1)b > f(a-1) then 2kb+f(a1)<2k2^k - b + f(a-1) < 2^k, and so we must have f(a1)=b1f(a-1) = b-1. On the other hand, if f(a1)>bf(a-1) > b, then <2k<2kb+f(a1)<2k+2k2< 2^k < 2^k - b + f(a-1) < 2^k + 2^{k-2}, and hence d(2kb+f(a1))<k1d(2^k - b + f(a-1)) < k-1, a contradiction. Thus f(a1)=b1f(a-1) = b-1.

Letting c=f(a)a=bac = f(a) - a = b - a, we have shown that f(a)=a+cf(a) = a + c implies f(a1)=a1+cf(a - 1) = a - 1 + c, and that there are arbitrarily large integers nn so that f(n)=n+cf(n) = n + c. It is now clear by induction that f(n)=n+cf(n) = n + c for all nn. \square

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.