Binary Bunch on November 3rd

Let S S denote a set of positive integers from 1 1 to k . k. Sort them

  • first in ascending order of the number of 1 1 's in their binary form
  • and then in ascending order in base 10.

For instance, if k = 12 k=12 , then S S would give the sorted sequence 1 , 2 , 4 , 8 , 3 , 5 , 6 , 9 , 10 , 12 , 7 , 11 , 1,2,4,8,3,5,6,9,10,12,7,11, where 1 1 10 = 101 1 2 11_{10}=1011_2 is the greatest integer in S S with three 1 1 's in its binary form.

If k = 3 11 , k = 3^{11}, what is the 8857 4 th 88574^\text{th} number in the new sequence sorted as above?


The answer is 7666.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Michael Huang
Nov 3, 2017

It appears there is no short,neat approach for this problem.


Counting Generalization


Let B j ( k ) B_j(k) denote the number of positive integers in S S containing j j number of 1 1 's. This can be expressed as B j ( k ) = { 0 j = 0 log 2 ( k ) + 1 j = 1 ( log 2 ( k ) j ) j 2 , k = 2 n , n Z 0 ( log 2 ( k ) j ) + B j 1 ( k 2 log 2 ( k ) ) j 2 , k 2 n B_j(k) = \left\{ \begin{array}{rl} 0 & j = 0\\ \lfloor \log_2(k) \rfloor + 1 & j = 1 \\ \dbinom{\log_2(k)}{j} & j \geq 2, \quad k = 2^n, n \in \mathbb{Z}_{\geq 0} \\ \dbinom{\lfloor \log_2(k) \rfloor}{j} + B_{j - 1}\left(k - 2^{\lfloor \log_2(k)\rfloor}\right) & j \geq 2, \quad k \neq 2^n \end{array} \right. If j = 0 j = 0 , clearly there is no positive integer that excludes 1 1 's.

If j = 1 j = 1 , then the integers with singles are of the form 2 p 2^p , where 0 p l o g 2 ( k ) 0 \leq p \leq \lfloor log_2(k)\rfloor .

Otherwise, if 2 j log 2 ( k ) 2 \leq j \leq \lceil \log_2(k) \rceil , the counting depends on the 2 2 -base-sum-representation of k k and the value of j j .

Subcase 1: If k 2 log 2 ( k ) = 0 k - 2^{\lfloor \log_2(k) \rfloor} = 0 , then k = 2 n k = 2^n for a positive integer n n . Then, we can freely count the number of j j -tuple integers with log 2 ( k ) \log_2(k) digits, which gives us ( log 2 ( k ) j ) \binom{\log_2(k)}{j} .

Subcase 2: Otherwise, we determine the number of ( j 1 ) (j - 1) -tuple integers for subset from 1 1 to k 2 log 2 ( k ) > 0 k - 2^{\lfloor \log_2(k) \rfloor} > 0 . Then, count all j t u p l e s j-tuples with log 2 ( k ) \lfloor \log_2(k)\rfloor digits.

Now, let's consider the leftmost digit, being 1 1 . If j 1 = 1 j - 1 = 1 , then we simply substitute ( k 2 log 2 ( k ) ) (k - 2^{\lfloor \log_2(k) \rfloor}) back to B 1 B_1 . Otherwise, j 1 2 j - 1 \geq 2 , which returns us to the subcases we consider. Repeat this until the sub B B 's in B j ( k ) B_j(k) terminate.


Problem


The value k = 3 11 k = 3^{11} can be presented as 3 11 = 2 17 + 2 15 + 2 13 + 2 12 + 2 9 + 2 8 = 2 7 + 2 6 + 2 5 + 2 4 + 2 3 + 2 + 1 3^{11} = 2^{17} + 2^{15} + 2^{13} + 2^{12} + 2^9 + 2^8 = 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2 + 1 or the binary representation 10101100111111101 1 2 101011001111111011_2 . Since we are interested in finding the integer in the ordered set, compute the total number of integers in binary form, starting from j = 1 j = 1 . Notice that the values in each log 2 \log_2 are in fact base- 2 2 exponents in decreasing order from the sum.

j j Substitution B j ( k ) B_j(k)
1 1 log 2 ( 3 11 ) + 1 \lfloor \log_2(3^{11})\rfloor + 1 18 18
2 2 ( 17 2 ) + 15 + 1 \dbinom{17}{2} + 15 + 1 152 152
3 3 ( 17 3 ) + ( 15 2 ) + 13 + 1 \dbinom{17}{3} + \dbinom{15}{2} + 13 + 1 799 799
4 4 ( 17 4 ) + ( 15 3 ) + ( 13 2 ) + 12 + 1 \dbinom{17}{4} + \dbinom{15}{3} + \dbinom{13}{2} + 12 + 1 2926 2926
5 5 ( 17 5 ) + ( 15 4 ) + ( 13 3 ) + ( 12 2 ) + 9 + 1 \dbinom{17}{5} + \dbinom{15}{4} + \dbinom{13}{3} + \dbinom{12}{2} + 9 + 1 7915 7915
6 6 ( 17 6 ) + ( 15 5 ) + ( 13 4 ) + ( 12 3 ) + ( 9 2 ) + 8 + 1 \dbinom{17}{6} + \dbinom{15}{5} + \dbinom{13}{4} + \dbinom{12}{3} + \dbinom{9}{2} + 8 + 1 16359 16359
7 7 ( 17 7 ) + ( 15 6 ) + ( 13 5 ) + ( 12 4 ) + ( 9 3 ) + ( 8 2 ) + 7 + 1 \dbinom{17}{7} + \dbinom{15}{6} + \dbinom{13}{5} + \dbinom{12}{4} + \dbinom{9}{3} + \dbinom{8}{2} + 7 + 1 26355 26355
8 8 ( 17 8 ) + ( 15 7 ) + ( 13 6 ) + ( 12 5 ) + ( 9 4 ) + ( 8 3 ) + ( 7 2 ) + 6 + 1 \dbinom{17}{8} + \dbinom{15}{7} + \dbinom{13}{6} + \dbinom{12}{5} + \dbinom{9}{4} + \dbinom{8}{3} + \dbinom{7}{2} + 6 + 1 33463 33463

So p = 1 8 B p ( k ) = 88047 \sum\limits_{p=1}^8 B_p(k) = 88047 . So we look at the last of the first 88574 88047 = 527 88574 - 88047 = 527 integers with nine 1 1 's. Digit-chasing, we have 111011111001 0 2 1110111110010_2 , which is equivalent to the integer 7666 \boxed{7666} .

Um. You say the answer is 7666 7666 , but you marked it as incorrect in your problem?

Ivo Zerkov - 3 years, 7 months ago

Log in to reply

Yes. Apologies. The answer I added before is incorrect. It's actually 7666 7666 . I am waiting for @Brilliant Mathematics or @Calvin Lin to change the answer. :)

Michael Huang - 3 years, 7 months ago

Log in to reply

Thanks. I've updated the answer to 7666.

Brilliant Mathematics Staff - 3 years, 7 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...