MathLabs

Problem 3

For positive integer kk, let f(k)f(k) be the number of integers in {k+1,…,2k}\{k+1,\ldots,2k\} whose binary expansion has exactly three 11s. Prove every positive integer mm occurs as f(k)f(k), and determine all mm for which exactly one kk has f(k)=mf(k)=m.
Step 1 of 5: Track one step of the function
In plain words

Track one step of the function

f(k+1)−f(k)∈{0,1}f(k+1)-f(k)\in\{0,1\}
Detailed analysis

Passing from kk to k+1k+1 removes k+1k+1 and adds 2k+12k+1 and 2k+22k+2. The binary expansion of 2k+22k+2 is that of k+1k+1 followed by a zero, so these two contributions cancel. Therefore f(k+1)=f(k)+1f(k+1)=f(k)+1 exactly when 2k+12k+1 has three 11s, and otherwise f(k+1)=f(k)f(k+1)=f(k).