
3. For a rational number $r$, its period is the length of the smallest repeating block in its decimal expansion. For example, the number $r=0.123123123 \cdots$ has period 3 . If $S$ denotes the set of all rational numbers $r$ of the form $r=0 . \overline{a b c d e f g h}$ having period 8 , find the sum of all the elements of $S$.


Solution: Let us first count the number of elements in $S$. There are $10^{8}$ ways of choosing a block of length 8. Of these, we shoud not count the blocks of the form abcdabcd, abababab, and aaaaaaaa. There are $10^{4}$ blocks of the form abcdabcd. They include blocks of the form abababab and aaaaaaaa. Hence the blocks of length exactly 8 is $10^{8}-10^{4}=99990000$.

For each block $a b c d e f g h$ consider the block $a^{\prime} b^{\prime} c^{\prime} d^{\prime} e^{\prime} f^{\prime} g^{\prime} h^{\prime}$ where $x^{\prime}=9-x$. Observe that whenever $0 . \overline{a b c d e f g h}$ is in $S$, the rational number $0 . \overline{a^{\prime} b^{\prime} c^{\prime} d^{\prime} e^{\prime} f^{\prime} g^{\prime} h^{\prime}}$ is also in $S$. Thus every element $0 . \overline{a b c d e f g h}$ of $S$ can be uniquely paired with a distinct element $0 . \overline{a^{\prime} b^{\prime} c^{\prime} d^{\prime} e^{\prime} f^{\prime} g^{\prime} h^{\prime}}$ of $S$. We also observe that

$$
0 . \overline{a b c d e f g h}+0 . \overline{a^{\prime} b^{\prime} c^{\prime} d^{\prime} e^{\prime} f^{\prime} g^{\prime} h^{\prime}}=0 . \overline{99999999}=1
$$

Hence the sum of elements in $S$ is

$$
\frac{99990000}{2}=49995000
$$
