A number is randomly selected from the $[0,1]$ interval. What is the probability that the digit 5 appears among the first $n$ digits of the selected number in its decimal form?
I. solution. Random selection is to be understood as follows: the probability that the selected number falls into any subinterval $[a, b]$, $[a, b)$, $(a, b]$, or $(a, b)$ of the $[0 ; 1]$ interval is equal to the length $|b-a|$ of the interval.

If the first $n$ digits of the selected number in its decimal form include the digit 5, then the selected number will be called a "good number". Let's try to form a picture of the distribution of good numbers. If $a_{1}, a_{2}, \ldots, a_{k}$ are digits different from 5 and $k \leqq n-1$, then every number in the right-open interval $\left[0, a_{1} a_{2} \ldots a_{k} 5 ; 0, a_{1} a_{2} \ldots a_{k} 6\right)$ is a good number.

Conversely, every good number belongs to an interval of the type mentioned above, because taking the first 5 digit - let its position be $m$, and let the preceding decimal digits be $a_{1}, a_{2}, \ldots, a_{m-1}$, then $m \leqq n$ and $a_{i} \neq 5$ if $i \leq m-1$, so the good number is in the following interval:

$$
\left[0, a_{1} a_{2} \ldots a_{m-1} 5 ; \quad 0,{ }_{1} a_{2} \ldots a_{m-1} 6\right)
$$

![](https://cdn.mathpix.com/cropped/2024_05_02_bd12e4241d2ffa78b744g-1.jpg?height=101&width=1027&top_left_y=741&top_left_x=538)

Our diagram illustrates the intervals containing good numbers for $n \leqq 2$.

The intervals of form (1) are disjoint (no two have a common point), so the sought probability $P$ is given by the sum of the lengths of such intervals. The length of (1) is $10^{-m}$, and the number of such intervals is the number of ways to choose $a_{1} a_{2} \ldots a_{m-1}$, which is $9^{m-1}$, and we need to sum the lengths $9^{m-1} \cdot 10^{-m}$ for $m=1,2, \ldots, n$.

$$
P=\frac{1}{10}+\frac{9}{10^{2}}+\frac{9^{2}}{10^{3}}+\ldots+\frac{9^{n-1}}{10^{n}}=\frac{1}{10}\left\{1+\frac{9}{10}+\left(\frac{9}{10}\right)^{2}+\ldots+\left(\frac{9}{10}\right)^{n-1}\right\}=1-\left(\frac{9}{10}\right)^{n}
$$

From (1), it is clear that we thought of the finite form of the decimal representation of numbers. However, according to the interpretation given in the first paragraph, our result does not change if we think of the infinite form.

Remarks. 1. The above solution used a section of the textbook marked as a "reading" section. 1

2. If $n \rightarrow \infty$, then $P \rightarrow 1$, so the probability that the decimal representation of a number randomly selected from $[0 ; 1]$ contains the digit 5: 1 (certain event). However, this was already implied by our interpretation.

II. solution. We determine the probability of the complementary event to the one in question.

Divide the $[0 ; 1]$ interval into $10^{n}$ equal subintervals of length $10^{-n}$, so the division points are those finite decimals that have at most $n$ decimal places, that is, the $10^{-n}$ multiples of the integers $1,2, \ldots, 10^{n}-1$. Thus, every number in each subinterval is a "not good" number if and only if the left endpoint of the interval is not a good number.

Among the left endpoints, those are not good numbers whose $10^{n}$-fold does not contain the digit 5, that is, all their digits are from the set $0,1,2,3,4,6,7,8,9$. Their number is $9^{n}$, so the total length of the not good intervals is $\left(\frac{9}{10}\right)^{n}$. This explains the simple result of the I. solution.[^0]


[^0]:    ${ }^{1}$ Czapáry E.-Gyapjas F.-Horvay Katalin-Pálmay L.: Mathematics for the 4th grade of high school, Tankönyvkiadó, Budapest, 1969. 269. page: Determining probabilities using geometric methods.