Let be the increasing sequence of positive integers whose binary representation has exactly ones. Let be the 1000th number in . Find the remainder when is divided by .
Problem 257
Official solutions — 2
Solution 1
Okay, an exercise in counting (lots of binomials to calculate!). In base 2, the first number is , which is the only way to choose 8 1's out of 8 spaces, or . What about 9 spaces? Well, all told, there are , which includes the first 1. Similarly, for 10 spaces, there are which includes the first 9. For 11 spaces, there are , which includes the first 45. You're getting the handle. For 12 spaces, there are , which includes the first 165; for 13 spaces, there are , so we now know that has exactly 13 spaces, so the digit is 1.
Now we just proceed with the other 12 spaces with 7 1's, and we're looking for the number. Well, , so we know that the digit also is 1, and we're left with finding the number with 11 spaces and 6 1's. Now which is too big, but Thus, the digit is 1, and we're now looking for the number with 9 spaces and 5 1's. Continuing the same process, , so the digit is 1, and we're left to look for the number with 8 spaces and 4 1's. But here , so N must be the last or largest 7-digit number with 4 1's. Thus the last 8 digits of must be , and to summarize, in base . Therefore, , and the answer is .
Solution 2
1. We need to find the 1000th number in the sequence of positive integers whose binary representation has exactly 8 ones.
2. The number of such integers with digits is given by the binomial coefficient , as we are choosing 8 positions out of to place the ones.
3. Calculate the binomial coefficients for and :
Since and , we know that the 1000th number must have 13 digits because .
4. The first 13-digit number in is the 496th number in . Therefore, we need to find the th 13-digit number in .
5. Consider the 13-digit binary numbers. The first digit must be 1 (since it is a 13-digit number). We now have 12 remaining positions with 7 ones and 5 zeros.
6. Calculate the number of 13-digit numbers starting with "10":
Since there are 330 such numbers, we need the th 13-digit number starting with "11".
7. Calculate the number of 13-digit numbers starting with "110":
Since there are 120 such numbers, we need the th 13-digit number starting with "111".
8. Calculate the number of 13-digit numbers starting with "1110":
Since there are 36 such numbers, we need the th 13-digit number starting with "1111".
9. Calculate the number of 13-digit numbers starting with "11110":
Since there are 8 such numbers, we need the th 13-digit number starting with "11111".
10. Calculate the number of 13-digit numbers starting with "111110":
Since there is 1 such number, we need the th 13-digit number starting with "111111".
11. Calculate the number of 13-digit numbers starting with "1111110":
Since there is 1 such number, we need the th 13-digit number starting with "1111111".
12. Calculate the number of 13-digit numbers starting with "11111110":
Since there is 1 such number, we need the th 13-digit number starting with "11111111".
13. Calculate the number of 13-digit numbers starting with "111111110":
Since there is 1 such number, we need the th 13-digit number starting with "111111111".
14. Calculate the number of 13-digit numbers starting with "1111111110":
Since there is 1 such number, we need the th 13-digit number starting with "1111111111".
15. Calculate the number of 13-digit numbers starting with "11111111110":
Since there is 1 such number, we need the th 13-digit number starting with "11111111111".
16. Calculate the number of 13-digit numbers starting with "111111111110":
Since there is 1 such number, we need the th 13-digit number starting with "111111111111".
17. Calculate the number of 13-digit numbers starting with "1111111111110":
Since there is 1 such number, we need the th 13-digit number starting with "1111111111111".
18. Calculate the number of 13-digit numbers starting with "11111111111110":
Since there is 1 such number, we need the th 13-digit number starting with "11111111111111".
19. Calculate the number of 13-digit numbers starting with "111111111111110":
Since there is 1 such number, we need the th 13-digit number starting with "111111111111111".
20. The 1000th number in is , which in decimal is .
21. Find the remainder when is divided by :
The final answer is .