3. Determine all natural numbers $n$ for which every number written with one seven and $n-1$ ones is prime.
Solution. The number $B$ written with one seven and $n-1$ ones is of the form $B=A_{n}+6 \cdot 10^{k}$ where $A_{n}$ is a number with $n$ ones and $0 \leq k \leq 6$. Then $n=6 k+r, k \geq 0,1 \leq r \leq 6$, so

$$
A_{n}=A_{6 k+r}=A_{6 k}+A_{r} \cdot 10^{6 t} \equiv A_{6 k}+A_{r} \equiv A_{r}(\bmod 7)
$$

If $6 \mid n$, then $3 \mid n$ and the sum of the digits of the number $B$ is $3 p+6$, which means it is a composite number. Let 6 not be a divisor of $n$. Then $A_{n} \equiv A_{r}(\bmod 7)$ and $A_{r}$ is not congruent to 0 modulo 7. Let us put $A_{r} \equiv k(\bmod 7)$. From the previous considerations, it follows that for this $k$ we can choose $t, 0 \leq t \leq 5$ such that

$$
6 \cdot 10^{t} \equiv-10^{t} \equiv-k(\bmod 7)
$$

so

$$
B=A_{n}+6 \cdot 10^{t} \equiv A_{r}+6 \cdot 10^{t} \equiv k-k=0(\bmod 7)
$$

i.e., $B$ is divisible by 7.

It remains to check the cases when $n \leq 6$. Clearly, for $n=6$ and $n=3$ all numbers are composite. For $n=5$ we have

$$
A_{5}+6 \cdot 10^{2} \equiv 2+12 \equiv 0(\bmod 7)
$$

for $n=4$ we have $1711=29 \cdot 59$, and for $n=2$ and $n=1$ these are the prime numbers 7, 17, and 71.