IMO 1990 SL 27
Find all natural numbers n for which every natural number
IMO 1990 SL 27
Origin: USS
Problem
Find all natural numbers n for which every natural number whose decimal representation has n −1 digits 1 and one digit 7 is prime.
Solution
Let us denote by An(k) the n-digit number which consists of n −1 ones and one digit seven in the k + 1-th rightmost position (0 \leqk < n). Then An(k) = (10n + 54 \cdot 10k −1)/9. We note that if 3 | n we have that 3 | An(k) for all k. Hence n cannot be divisible by 3. Now let 3 ∤n. We claim that for each such n \geq5, there exists k < n for which 7 | An(k). We see that An(k) is divisible by 7 if and only if 10n −1 \equiv2 \cdot 10k (mod 7). There are several cases. n \equiv1 (mod 6). Then 10n −1 \equiv2 \equiv2 \cdot 100, so 7 | An(0). n \equiv2 (mod 6). Then 10n −1 \equiv1 \equiv2 \cdot 104, so 7 | An(4). n \equiv4 (mod 6). Then 10n −1 \equiv3 \equiv2 \cdot 105, so 7 | An(5). n \equiv5 (mod 6). Then 10n −1 \equiv4 \equiv2 \cdot 102, so 7 | An(2). The remaining cases are n = 1, 2, 4. For n = 4 the number 1711 = 29 \cdot 59 is composite, while it is easily checked that n = 1 and n = 2 are solutions. Hence the answer is n = 1, 2.