Maths Olympiad Prep

Library / /3 of 3

Number theory Difficulty 8.8 Shortlist Prove it Taiwan

For any positive integer nn, consider its binary representation. Denote by f(n)f(n) the number we get after removing all the 0's in its binary representation, and g(n)g(n) the number of 1's in the binary representation. For example, f(19)=7f(19) = 7 and g(19)=3g(19) = 3. Find all positive integers nn that satisfy
n=f(n)g(n). n = f(n)^{g(n)}.

Solution

Let g(n)=kg(n) = k. Then f(n)=2k1f(n) = 2^k - 1, and so we just need to determine all kk such that (2k1)k(2^k - 1)^k has kk 1's in its binary representation. To do this, we can simply expand
(2k1)k=i=0k(1)i(ki)2k2ki=i=0k12(k2i)2k22ki(k2i+1)2k22kik+((k+1)mod2). (2^k - 1)^k = \sum_{i=0}^{k} (-1)^i \binom{k}{i} 2^{k^2 - ki} = \sum_{i=0}^{\lfloor \frac{k-1}{2} \rfloor} \binom{k}{2i} 2^{k^2 - 2ki} - \binom{k}{2i+1} 2^{k^2 - 2ki - k} + ((k+1) \bmod 2).
Here (k+1)mod2(k+1) \bmod 2 is 1 if kk is even and 0 if kk is odd. Write s(k,i)s(k, i) for
(k2i)2k22ki(k2i+1)2k22kik \binom{k}{2i} 2^{k^2 - 2ki} - \binom{k}{2i+1} 2^{k^2 - 2ki - k}
Then we know that
s(k,i)<2k2k22ki=2k2(2i1)k, s(k, i) < 2^k 2^{k^2 - 2ki} = 2^{k^2 - (2i-1)k},
and we also know that 2k2(2i+1)k2^{k^2 - (2i+1)k} divides s(k,i)s(k, i). Therefore
f((2k1)k)=i=0k12f(s(k,i))+((k+1)mod2). f((2^k - 1)^k) = \sum_{i=0}^{\lfloor \frac{k-1}{2} \rfloor} f(s(k, i)) + ((k + 1) \bmod 2).
Since s(k,i)/2k2(2i+1)k(k2i+1)mod2ks(k,i)/2^{k^2-(2i+1)k} \equiv -\binom{k}{2i+1} \bmod 2^k, we know that f(s(k,i))=f(s(k,i)/2k2(2i+1)k)f(s(k,i)) = f(s(k,i)/2^{k^2-(2i+1)k}) is at least
klog2(k2i+1). k - \left\lfloor \log_2 \binom{k}{2i+1} \right\rfloor.
Now we can proceed in two ways.

Approach 1. If k3k \ge 3, then we get
s(k,0)+s(k,1)2klog2klog2(k3)>2k4log2k s(k, 0) + s(k, 1) \ge 2k - \lfloor \log_2 k \rfloor - \left\lfloor \log_2 \binom{k}{3} \right\rfloor > 2k - 4 \log_2 k
Therefore 4log2k>k4 \log_2 k > k and so k<16k < 16. Now, plugging in
k2klog2klog2(k3) k \ge 2k - \lfloor \log_2 k \rfloor - \left\lfloor \log_2 \binom{k}{3} \right\rfloor
for k<16k < 16, we get k=4,5,6,7,8,9k = 4, 5, 6, 7, 8, 9 and the equality holds in all cases.

However, when k5k \ge 5 we have
f((2k1)k)>f(s(k,0))+f(s(k,1))+f(s(k,2))k+1, f((2^k - 1)^k) > f(s(k, 0)) + f(s(k, 1)) + f(s(k, 2)) \ge k + 1,
which is a contradiction. When k=4k = 4, we have f(154)s(4,0)+s(4,1)+1>5f(15^4) \ge s(4, 0) + s(4, 1) + 1 > 5. Therefore, we reach a contradiction from k3k \ge 3, showing that k<3k < 3 must hold. It is clear that k=1,2k = 1, 2 both work and we get n=1,9n = 1, 9. \square

Approach 2. It is clear that k=1,2k = 1, 2 both work, so we will assume that k3k \ge 3 from now on. If kk is odd, then we have s(k,(k1)/2)=k2k1s(k, (k-1)/2) = k \cdot 2^k - 1, showing that f(s(k,(k1)/2))kf(s(k, (k-1)/2)) \ge k. We also have f(s,0)1f(s, 0) \ge 1, so we already get a contradiction. Therefore, kk must be even, and we have f(s(k,0)),f(s(k,k/21))klog2kf(s(k, 0)), f(s(k, k/2-1)) \ge k - \lfloor \log_2 k \rfloor. Thus, 2log2kk2 \lfloor \log_2 k \rfloor \ge k, and we get k=4k = 4. However, it is easy to compute that f(154)4f(15^4) \ne 4, showing that k3k \ge 3 does not work at all. \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 translated into English from en; metadata (topic, difficulty) added by this project.