MODBasic AlternativeBase AIME Difficult
2004


Problem - 4177

Let $\mathbb{S}$ be the set of integers between $1$ and $2^{40}$ that contain two $1$s when written in base $2$. What is the probability that a random integer from $\mathbb{S}$ is divisible by $9$?


Answer     $\dfrac{133}{780}$

Because $2^6\equiv 1\pmod{9}$, we find $2^{n+6}\equiv 2^n\pmod{9}$ holds for any integer $n$. This means that power of $2$ forms a cyclic of length $6$ in MOD $9$: $2$, $4$, $-1$, $-2$, $-4$, and $1$.

Any number that contains two $1$'s when written in base $2$ must be in the form of $(2^a + 2^b)$ when written in base $10$ where $a\ne b$. In order to make it a multiple of $9$, or $2^a + 2^b\equiv 0\pmod{9}$, $a$ and $b$ must be in the following pairs $$(6k, 6m+3), (6k+1, 6m+4), (6k+2, 6m+5)$$

where $k$ and $m$ are two integers.

Within the given range, $1=2^0$ and $2^{40}$, there are $7\times 7=49$ choices for the first pair, $7\times 6=42$ choices for the second pair and $7\times 6=42$ choices for the third pair. Therefore there are totally $49+42+42=133$ qualified numbers. Meanwhile, there are totally $C_{40}^2=780$ numbers that have exactly two $1$s in their binary representations. Thus the final answer is $\boxed{\dfrac{133}{780}}$.

report an error