Determine the prime numbers $p$ such that the decimal representation of the fraction $\frac{1}{p}$ has a period of length 5.

Note: If the decimal representation of a number has a sequence of digits that repeats periodically, the length of the smallest sequence of digits that repeats is the length of the decimal representation. For example, $61 / 495=0.1232323 \ldots$, although 23, 2323 are sequences of digits that repeat in the decimal representation, the length of the smallest sequence is 2 and this is the period length.
Solution

Let $q$ be the size of the non-periodic part and $\overline{a b c d e}$ be the period of the decimal representation of $1 / p$. Thus, if we represent the digits of the non-periodic part with the symbol $\star$, we have

$$
\begin{aligned}
\frac{1}{p} & =0, \star \star \ldots \star \text { abcdeabcde } \ldots \\
\frac{10^{q}}{p} & =\star \star \ldots \star, \text { abcdeabcde } \ldots \\
\frac{10^{q}}{p} & =M+\frac{\text { abcde }}{10^{5}-1}
\end{aligned}
$$

In the last equation, we represent by $M$ the integer to the left of the decimal point in the decimal representation of $10^{q} / p$ or, if you prefer, the integer part of the number in question. Multiplying the previous equation by $\left(10^{5}-1\right) p$, we get

$$
\begin{aligned}
& 10^{q}\left(10^{5}-1\right)=\left(10^{5}-1\right) \cdot p \cdot M+\text { abcde } \cdot p \\
& 10^{q}\left(10^{5}-1\right)=\left[\left(10^{5}-1\right) \cdot M+\text { abcde }\right] \cdot p
\end{aligned}
$$

consequently, $p \mid 10^{q}\left(10^{5}-1\right)$. The only prime divisors of $10^{q}$ are 2 and 5, and clearly neither of them produces a decimal with a period of 5. We are left to analyze the prime factors of $10^{5}-1=9 \cdot 11111=3^{2} \cdot 41 \cdot 271$. Among the three prime numbers that appear in the factorization above, we can check that 41 and 271 are the only ones that produce a decimal with a period of 5.

Note: If $p$ is a prime different from 2 and 5 and $k$ is the smallest positive exponent such that $p$ divides $10^{k}-1$, it is possible to show that the decimal expansion of $1 / p$ has a period of length $k$.