# Difference between revisions of "2012 AIME II Problems/Problem 12"

## Problem 12

For a positive integer $p$, define the positive integer $n$ to be $p$-safe if $n$ differs in absolute value by more than $2$ from all multiples of $p$. For example, the set of $10$-safe numbers is $\{ 3, 4, 5, 6, 7, 13, 14, 15, 16, 17, 23, \ldots\}$. Find the number of positive integers less than or equal to $10,000$ which are simultaneously $7$-safe, $11$-safe, and $13$-safe.

## Solution

We see that a number $n$ is $p$-safe if and only if the residue of $n \mod p$ is greater than $2$ and less than $p-2$; thus, there are $p-5$ residues $\mod p$ that a $p$-safe number can have. Therefore, a number $n$ satisfying the conditions of the problem can have $2$ different residues $\mod 7$, $6$ different residues $\mod 11$, and $8$ different residues $\mod 13$. The Chinese Remainder Theorem states that for a number $x$ that is $a$ (mod b) $c$ (mod d) $e$ (mod f) has one solution if $gcd(b,d,f)=1$. For example, in our case, the number $n$ can be: 3 (mod 7) 3 (mod 11) 7 (mod 13) so since $gcd(7,11,13)$=1, there is 1 solution for n for this case of residues of $n$.

This means that by the Chinese Remainder Theorem, $n$ can have $2\cdot 6 \cdot 8 = 96$ different residues mod $7 \cdot 11 \cdot 13 = 1001$. Thus, there are $960$ values of $n$ satisfying the conditions in the range $0 \le n < 10010$. However, we must now remove any values greater than $10000$ that satisfy the conditions. By checking residues, we easily see that the only such values are $10006$ and $10007$, so there remain $\fbox{958}$ values satisfying the conditions of the problem.

### Solution 2 (Probability)

Note that $\operatorname{lcm}(7, 11, 13)=1001$ and $10000=1001\cdot10-10$. Now, consider any positive integer $n$ such that $1\le n\le 10010$. Since all $7$-safe numbers are of the form $7k+3$ or $7k+4$, the probability that $n$ is $7$-safe is $\frac{2}{7}$. Similarly, the probability that $n$ is $11$-safe is $\frac{6}{11}$ and the probability that $n$ is $13$-safe is $\frac{8}{13}$. Furthermore, since $7, 11, \text{ and } 13$ are all relatively prime, $n$ being $7$-safe, $11$-safe, and $13$-safe are all independent events. Thus, the number of positive integers less then or equal to $10010$ which are simultaneously $7$-safe, $11$-safe, and $13$-safe is $10010\left(\frac{2}{7}\right)\left(\frac{6}{11}\right)\left(\frac{8}{13}\right)=960$. However, the problem asks for numbers less than or equal to $10000$, so we must subtract any numbers we counted which are greater than $10000$. This is easy; we can see that $10006$ and $10007$ were overcounted, so the answer is $960-2=\boxed{958}$.

-brainiacmaniac31