Problem:
Let be the set of integers between and whose binary expansions have exactly two 's. If a number is chosen at random from , the probability that it is divisible by is , where and are relatively prime positive integers. Find .
Solution:
An element of has the form , where , and , so has elements. Without loss of generality, assume . Note that divides if and only if divides , that is, when . Because , and , and , respectively, conclude that when for positive integers . But implies that , so there are ordered pairs that satisfy . Because , conclude that . The number of multiples of in is therefore . Thus the probability that an element of is divisible by is , so .
There are such numbers, which can be viewed as strings of length containing 's and two 's. Express these strings in base- by partitioning them into groups of starting from the right and one group of , and then expressing each -digit binary group as a digit between and . Because , a divisibility test similar to the one for in base can be used. Let represent a -digit number in base . Then
Thus a base- number is divisible by if and only if the sum of the digits in the even-numbered positions differs from the sum of the digits in the odd-numbered positions by a multiple of . Because the given base- string has at most two nonzero digits, and its greatest digit is at most or , the two sums must differ by . There are two cases. If the first (leftmost) digit in the base- string is , then the other must be in an odd-numbered group of that has the form . There are seven such numbers. In the second case, if the first digit in the base- string is , one of the 's must be in an even-numbered group of , the other must be in an odd-numbered group, and they must be in the same relative position within each group, that is, both , both , or both . There are such numbers. Thus the required probability is .
The problems on this page are the property of the MAA's American Mathematics Competitions